I'm trying to update multiple records and then send email notification using custom list button.
For this I need to get few fields off the related list.
One option would be traverse thru the related list using getElements... function, but it might not have all the fields you need (solution is already posted).
An alternative would be a SOQL query with required fields and selected ids you get from checkboxes. A.i.:
var records = {!GETRECORDIDS($ObjectType.obj__c)};
var soqlQ="SELECT name FROM obj__c WHERE Id='"+records+"'";
var customObj = sforce.connection.query(soqlQ);
var soqlRes = customObj.getArray("records");
The problem here is that syntax is not supported by SOQL:
INVALID_QUERY_FILTER_OPERATOR', faultstring:'INVALID_QUERY_FILTER_OPERATOR: SELECT name FROM obj__c WHERE Id='a0OaxxxxxxxxMRDy2,a0OaxxxxxxxxLfbwY'
Alternative would be to construct the SOQL query in a dynamic way:
SELECT name FROM obj__c WHERE id='a0OaxxxxxxxxMRDy2' or id='a0OaxxxxxxxxMRDy2'
The trouble I have is that I do not know how to do one in JavaScript.
Any help or alternative ideas are very appreciated. Thanks, ~dzh
Edit: Solution is
var records = {!GETRECORDIDS($ObjectType.obj__c)}.toString().replace(/,/g , "','");
var soqlQ="SELECT name FROM obj__c WHERE Id in ('"+records+"')";