How to Use SOQL Query in Javascript

Force.com platform provides a AJAX Toolkit API which provides features to work with sObjects using JavaScript without the help of Apex codes. It is not always necessary to write an apex class for every visualforce page we build. First include AJAX Toolkit API Library file <script src=”/soap/ajax/25.0/connection.js” type=”text/javascript”></script> 1. Query Data as follows: //get Accounts using SOQL Query var result = sforce.connection.query(“SELECT Id, Name FROM Account LIMIT 5”); . var records = result.getArray(“records”); // This step is important, as we get records as an assosiative array. if( records.length > 0 && records[0].Id != null ){    var accId = records[0].Id; … Continue reading How to Use SOQL Query in Javascript