function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Frenchy52Frenchy52 

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; }

 


Message Edited by Frenchy52 on 07-14-2009 03:31 PM
Message Edited by Frenchy52 on 07-15-2009 10:20 AM
DevAngelDevAngel

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+"'");