-
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 Salesforce Marketing Cloud Can Help You Create Exceptional Customer Experiences?
What is Salesforce Marketing Cloud? Salesforce Marketing Cloud is a platform that gives marketers a rich set of tools that are specifically designed and hand-selected to effectively interact and manage your…
How Salesforce CPQ Enhances Your Sales Team’s Efficiency
In today's fast-paced business environment, efficiency and accuracy are paramount for sales success. Configure, Price, Quote (CPQ) software has emerged as a vital tool to…
Salesforce Loops in Apex | The Developer Guide
Introduction A loop is a programming structure that repeats a sequence of instructions again and again until a specific/desired condition is met. In a loop…
Popular Salesforce Videos
Connect Google Ads Lead Form Extension to Salesforce
Do you need to collect leads from your Google Ads Lead Form extension and receive them directly in your Salesforce org? We demo how to…
Salesforce Automation Tools
What all automation tools available in Salesforce? Learn more about automation tools - a) Process Builder b) Lighting Flow c) Approval process d) Workflow rules…
How to Close Complex Deals Fast with Salesforce CPQ+
CPQ Salesforce, or Configure, Price, Quote Software by Salesforce is a sales tool for companies to provide accurate pricing with any given product configuration scenario.…