0

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?

{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/32.0/apex.js")}

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++) {
    console.log(records[i]);
  }
}

Thanks in advance!

2

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

Example

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 '16 at 15:38
  • Haha..It happens sometimes..no worries :) – Karthikeya Pammi Aug 30 '16 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.