You need to sign in to do that
Don't have an account?
Pulling multiple fields From Related objects
I have a master record where i am pulling in one field the name of the related accounts that sit on a related object.
The following code works to pull one fields from the related objects but when I try to querry on 3 fields the code does not work anymore.
Code that works:
result1 = sforce.connection.query("Select Related_Company_Name__c from Transaction_Relationship__c where Type__c='Buyer / Investor' and Transaction__c='"+tarx.Id+"'"); var rSize = result1.size; var NewValue =""; var longName = " "; if(rSize>1){ var i = 0; for (i = 0 ; i<rSize;i++){ longName=longName + "; "+result1.records[i].Related_Company_Name__c ; } var NameLength = longName.length; longName = longName.substring(3,NameLength); } if(rSize == 1){ longName=" "+result1.records.Related_Company_Name__c; }
Here is the code that does not work:
result1 = sforce.connection.query("Select Related_Company_Name__c from Transaction_Relationship__c where Type__c='Buyer / Investor' and Transaction__c='"+tarx.Id+"'"); result2 = sforce.connection.queryMore("Select Related_Company_Prime__c from Transaction_Relationship__c where Type__c='Buyer / Investor' and Transaction__c='"+tarx.Id+"'"); var rSize = result1.size; var NewValue =""; var longName = " "; if(rSize>1){ var i = 0; for (i = 0 ; i<rSize;i++){ longName=longName + "; "+result1.records[i].Related_Company_Name__c+result2.records[i].Related_Company_Prime__c ; } var NameLength = longName.length; longName = longName.substring(3,NameLength); } if(rSize == 1){ longName=" "+result1.records.Related_Company_Name__c+result2.records[i].Related_Company_Prime__c; }
That's not a relationship query. And why are you call query twice? Why not expand the select list of query to include both fields that you want?
result1 = sforce.connection.query("Select Related_Company_Name__c, Related_Company_Prime__c from Transaction_Relationship__c where Type__c='Buyer / Investor' and Transaction__c='"+tarx.Id+"'");