-
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
Salesforce Marketing Cloud and Its Benefits
Managing customer is a crucial aspect of running a successful business. Salesforce marketing cloud is a customer relationship management tool for marketers. It is helpful in creating…
Benefits of Combination of Artificial Intelligence and CRM
Customer Relationship Management at present benefits significantly from the recent improvements in the field of Artificial Intelligence. CRM involves efficient management of data which is…
How can Salesforce and Outlook Integration Optimize Sales Process?
Salesforce is a cloud-based CRM software that acts as a software-as-a-service (SaaS) provider, developed to make organizations function efficiently and profitably by reducing the cost…
Popular Salesforce Videos
What is Record Types in Salesforce?
Record Types is where you have multiple page layouts to a specific profile. Watch this video to learn all about it.
How Can Salesforce Marketing Cloud Help You Grow Your Business Exponentially?
Salesforce Marketing Cloud can help you take your marketing to the next level by providing an all-in-one platform that helps you strategize across multiple channels.…
What is Sales Cloud in Salesforce? | How it can Help Any business?
In this video, Shrey is not only teaching but also demonstrating the concept of Sales Cloud in Salesforce. 1. What is sales cloud in Salesforce?…