I'm trying to make a custom link that executes some JavaScript in order to look up an Account, but running into an issue. I expect to get the entire Account back, but I'm only getting an sforce.Xml object with the Account Id and its type. Any pointers on what I'm doing incorrectly with the code below?


document.onblur = function() {
  var query = sforce.connection.query("SELECT Id FROM Account WHERE Name LIKE 'Edge' LIMIT 5");
  records = query.getArray("records");
  for (var i = 0; i < records.length; i++) {

Thanks in advance!


1 Answer 1


You are querying for only the Id in the SOQL query. Change the query by adding more field API names to it.


var query = sforce.connection.query("SELECT Id, Name,RecordTypeId, Phone FROM Account WHERE Name LIKE 'Edge' LIMIT 5");

Unless you specify the exact fields, they are not retrieved by the query.

If querying for a custom field, don't forget to append __c to the name. Example:custom_field__c

  • Oh wow...haha thank you very much - what a stupid mistake :)
    – McD
    Aug 30, 2016 at 15:38
  • Haha..It happens sometimes..no worries :) Aug 30, 2016 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.