-
How can we fetch data without using Controller functions on salesforce VisualForce page?
Hi All,
I am in a scenario where i need to search data using keypress action from a list of accounts and i need to use javascript function in this not controller function.Is there any way to do this.i have written the following code:
<apex:page controller="SearchAccountJS">
<script>
function search(){
if( name != ''){
var str=sforce.connection.query('SELECT id,Name,AnnualRevenue FROM Account WHERE Name like \''+name+'%\'');
records= str.getArray("records");
alert('1'+records);}
else{
var str = sforce.connection.query('SELECT id,Name,AnnualRevenue FROM Account');
records=str.getArray("records");
alert('2'+records);}
</script>
<apex:form >
<apex:actionFunction name="ApexMethod" action="search()" rerender="accountTable"/>
<apex:pageBlock >
<apex:outputText value="Account Name"/>
<apex:inputText value="{!name}" onkeyup="ApexMethod" />
<apex:pageBlockSection id="accountTable" columns="3">
<apex:pageblocktable value="{!accounts}" var="acc">
<apex:column value="{!acc.Name}"/>
<apex:column value="{!acc.id}"/>
<apex:column value="{!acc.AnnualRevenue}"/></apex:pageblocktable>
</apex:pageBlockSection></apex:pageBlock>
</apex:form>
</apex:page>Controller here is only used for printing list of accounts.
Log In to reply.
Popular Salesforce Blogs
What are Auto-Launched Flows? | All You Need to Know
What are Auto-launched Flows? A certain event, such as the creation or updating of a record or the receiving of a platform event, can automatically…
New release of Salesforce Marketing Cloud went live on June 17
Good news for all those who are eagerly waiting for Salesforce Marketing Cloud new release. With great new features and overall enhancements, the Salesforce Marketing…
Case Study on Global Pharma Tendering Solution
Enhancing tendering operations across multiple markets in the pharmaceutical industry through a unified solution within Salesforce. In the dynamic and competitive pharmaceutical industry, the efficient…
Popular Salesforce Videos
Heroku | Salesforce Development Course
Knowledge of Heroku is also required to crack the Salesforce PD 1 Certification Examination. Let’s understand what Heroku is and what are its uses, in…
5 Reasons To Choose Marketing Automation For Your Business | Salesforce
With the advancement in technology, it has become imperative to move towards more advanced methods to grow your business. Marketing automation is one method that…
How Will Salesforce Career Look Like 3 Years From Now?
In this video, Shrey shares his opinions about How will Salesforce career look like 3 years from now. Watch and learn. If you have any…