-
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

Fair Interview Conversation with Certified Salesforce Business Analyst
You may have noticed that last month, the whole Trailblazer community was counting the days until July 11 - the date on which the Salesforce…

Making Financial Services Firms Thrive Amidst Challenges in 2024
A competitive market along with a challenging economic climate has made it tough for financial services companies to acquire new customers, and provide better customer…

Setting SSO Between Salesforce and Okta’s Salesforce.com Standard Application using SAML 2.0 protocol
SSO(Single Sign On between Okta(Salesforce.com application) as Identity Provider and Salesforce as Service Provider) Steps to setup SSO between Salesforce and Okta’s Salesforce.com Application:- Go…
Popular Salesforce Videos
How to Prepare for Salesforce Platform App Builder (CRT-402) ?
The Salesforce Platform App Builder certification focuses on the different declarative functions available to an admin. Development and code are not included, but it focuses…
How to Get Experience Without the Job? | Salesforce Learning
Want to get experience without the job? Watch the full episode here: https://youtu.be/oG8sHOW8GI4 Shrey is a Chief Executive Officer at Cyntexa, a SILVER Salesforce Consulting…
How to Learn Salesforce Development | Salesforce learning steps for beginners | Trailhead demo
In this video, we shared the steps to learn salesforce lightning basics, salesforce apex development, CRM in online for free from scratch very quickly. Learn salesforce…