-
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
Salesforce Field Service Lightning: Features and Benefits
As Salesforce Partners, We understand the importance of providing excellent customer service. It is crucial to ensure customer satisfaction, which ultimately leads to business growth.…
Salesforce Winter '25 Highlights
Winter is coming, so be sure to bundle up with the features in Salesforce’s Winter '25 Release. Come out of the cold, cozy up by…
To Do Checklist Before Code Commit In Production
TO DO CHECKLIST BEFORE CODE COMMIT IN PRODUCTION Proper commenting in code (Test Class, Apex Class, Trigger, Vf page), if you modified or create new…
Popular Salesforce Videos
Salesforce Developer Tutorial - How and When to Use Apex Managed Sharing
In this episode, we go over what Apex Managed Sharing is in Salesforce when you should actually use apex managed sharing and how to actually…
In App Guidance | Salesforce Tutotial
In this video, we take a look at one of the new features from the Salesforce Summer '19 release - In-App Guidance. We explain what…
Salesforce TrailheaDX '18 Opening Keynote - Part 4: Build Apps Fast
Salesforce TrailheaDX ’18 Opening Keynote – Part 1: Create Connected Customer Experiences TrailheaDX ’18 Opening Keynote – Part 2: Salesforce Platform TrailheaDX ’18 Opening Keynote…