-
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
How To Create Custom Settings And Custom Objects | Salesforce Developer Guide
Custom Settings Custom settings are similar to custom objects which allow us to customize org data. Following are the steps to create Custom settings:- 1.…
Avoiding Race Conditions
An action function provides a way to submit a form programmatically via a JavaScript function call. When an action function is executed from a JavaScript event…
What is Salesforce Data Migration Solution?
Salesforce, a leading customer relationship management (CRM) platform, offers businesses a powerful set of tools to manage their sales, marketing, and customer service activities. As…
Popular Salesforce Videos
How to Connect to External Data | Salesforce
An external data source specifies how to access an external system. Salesforce Connect uses external data sources to access data that's stored outside your Salesforce…
Email-to-Case Advance | Clean Case Comments
Save your support reps from ‘Click fatigue’ while hastening the resolution of customer cases. Get Email to Case Advance, the much-needed power booster for your…
Top 50 Salesforce Lightning Interview Questions And Answers | Salesforce Lightning Interview
This video by MindMajix includes all the frequently asked Interview questions that give you an idea to crack your Salesforce Lightning interview smartly. These Interview…