-
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
Integrating Salesforce and Jira for a Secure Bidirectional Sync
Customers want personalized experiences. In order to give customers what they want, you need to integrate the tools your teams use to serve them. Integrating…
Creating and Populating a Wrapper in Apex
As Apex is a statically typed language, you must choose only one object type per list to iterate. What if you want to iterate an…
Salesforce Sales Cloud Innovations – Your Key to Higher Revenue
Sales have gone through a tremendous evolution over the years, starting from door-to-door to using advanced technologies. And now they’ve stepped into a hybrid age…
Popular Salesforce Videos
5 Service Cloud Dashboards For Your Board | Webinar
Discover the Power of Service Cloud Dashboards! Watch AblyPro's exciting webinar video on 5 Service Cloud Dashboards For Your Board' to unlock the secrets of…
Salesforce Lightning Development Tutorial - Lightning Components in Visualforce
Salesforce Lightning Custom Component Development Tutorial for Beginners Learn how to embed lightning components in a Visualforce page. 3 Steps Add apex:includeLightning tag in your…
Use Salesforce Notification Builder to Get Notifications to the Right Users in the Right Apps
Did you know you can use Notification Builder to create custom notifications for teams, task queues, and public groups? You can also replace standard notifications…