sforce connect : The version of the AJAX Toolkit is in the URL. After this script executes, the toolkit is loaded and a global object, sforce. connection , is created. This object contains all of the API calls and AJAX Toolkit methods, and manages the session ID.
To get the list of records from the result You need result.getArray("records") to get the records
complete code fot the same is:
function soqlQuery(){ try{ sforce.connection.sessionId = '{!$Api.Session_ID}'; var result = sforce.connection.query("SELECT Id, Name from Account",{ onSuccess : function(result){ alert('I am in 2'); var records = result.getArray("records"); console.log('==========records======='+records); }, onFailure : function(error){ } }); }catch(e){ alert(e); } } [removed]=function(){ soqlQuery(); }
and check browser console.. The version of the AJAX Toolkit is in the URL. After this script executes, the toolkit is loaded and a global object, sforce. connection , is created. This object contains all of the API calls and AJAX Toolkit methods, and manages the session ID.