-
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 Schedule-Triggered Flows? | The Ultimate Guide
What are Schedule-triggered Flows? Schedule-triggered flows start up at predetermined intervals and let you automate Salesforce activities. Teams can greatly benefit from this kind of…
How to disable Two Factor Authentication in Salesforce?
Hey there! Maybe you are using developer edition of salesforce for development purpose and let me guess, you login from different computers to your dev…
Salesforce Sales Cloud - All You Need To Know
Sales Cloud by Salesforce is the perfect platform for organizing and streamlining your sales processes. From creating product logs to creating campaigns and managing contacts,…
Popular Salesforce Videos
About Queueable Apex | Asynchronous Apex in Salesforce | Learn Salesforce Development
Queueable apex is an asynchronous apex method. It's similar to the @future method. By using this queueable interface, we can process an Apex that runs…
What is Vlocity (Salesforce Industries) and How It Can Help You Save Millions?
Know What is Vlocity (Salesforce Industries) & How It Can Help You Save Millions with Salesforce Hulk i.e Shrey Sharma in this live webinar. Discover…
Insert Data in Salesforce Using Standard Controller
Standard controllers provides ability to access and interact with structured business data contained in records displays in the proper user interface. Standard controller tasks: controlling…