-
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
Your Complete Guide to Salesforce Nonprofit Cloud
Aside from Sales Cloud, Service Cloud, and Marketing Cloud, Salesforce also has a product designed specifically for nonprofit organizations – Nonprofit Cloud. Salesforce’s Nonprofit Cloud…
What is the Non-Profit Success Pack in Salesforce?
The Salesforce Non-Profit Success Pack (NPSP) is a free solution available to nonprofits through the Salesforce AppExchange. It was created to help nonprofits use CRM…
These 5 Steps Will Help You Improve the Health of Your Salesforce Data
Companies struggling to maintain the quality health of their data should not expect the deluge of data to slow down anytime soon. In fact, the…
Popular Salesforce Videos
Add Intelligence to Any Salesforce App with Einstein Discovery
Bring intelligence in the context on any Force.com app thanks to the power of Einstein Data Discovery. Any Salesforce Admin or Developer can add in…
Use Case Hierarchy to Link Cases in Salesforce
Want to link your cases, so you and your team have a complete view of what’s going on with a customer? Do you want to…
Getting Started with Salesforce Lightning Process Builder
Process Builder is a point and click tool that makes it easy to automate many common Salesforce tasks. Learn how to design and build effective…