You need to sign in to do that
Don't have an account?

How to use soql query in visualforce page javascript?
Hi All,
Below is the javascript function in my Visualforce page.
function ownerchange(){
var leadrec = sforce.connection.query('select Id fom Account');
alert(leadrec);
}
My goal is to retreive the Sobject Id during runtime in javascript using visualforce page.
I tried sforce.connection query, but there is no luck with that. If there is any alternatice, please let me know.
Thanks!!
Below is the javascript function in my Visualforce page.
function ownerchange(){
var leadrec = sforce.connection.query('select Id fom Account');
alert(leadrec);
}
My goal is to retreive the Sobject Id during runtime in javascript using visualforce page.
I tried sforce.connection query, but there is no luck with that. If there is any alternatice, please let me know.
Thanks!!
please refer this http://www.sfdcpoint.com/salesforce/soql-query-in-javascript-example/ it will help you for sure
Mark this as solved if this helps you
Good luck !
{!REQUIRESCRIPT("/soap/ajax/24.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/24.0/apex.js")}
try{
var query = "SELECT Id,Name from Account LIMIT 2";
var records = sforce.connection.query(query);
var records1 = records.getArray('records');
alert(records);