-
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 Does Salesforce CRM Empower Insurance Organizations?
Salesforce for insurance makes the lives easier for both the insurance agents and the companies. The world’s leading CRM, Salesforce, allows you to manage your…
Here's What To Expect From Salesforce's TrailheaDX 2021
TrailheaDX is the year's most exciting event for Trailblazers who want to learn new ways to build apps on Salesforce and expand the Salesforce Customer…
Top Things You Need to Know About Communities in Salesforce
Salesforce Communities is a stage that permits our clients to interface with individuals outside their association utilizing information, cooperation, and substance. While most Salesforce clients…
Popular Salesforce Videos
Salesforce Sandbox Tutorial | Salesforce Training Videos For Beginners
The Salesforce Sandbox is a copy of a production Salesforce environment used for a variety of purposes, commonly including testing and development. Here's how Salesforce…
Introduction to SFDX Deploy Tool for Windows | Salesforce Integration Tutorial Series
In this tutorial, we're going to learn about SFDX Deploy Tool for Windows. SFDX Deploy Tool helps you to deploy metadata from one Salesforce org…
Salesforce with Google Drive Integration
The Agenda of today's video is how to connect google drive with Salesforce using files connect. This Video is new in our learning video series…