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
RWC Jr.ax150RWC Jr.ax150 

Creating join w/ Query

Trying to create a join  - yes I know there is no join capability currently - hence my struggle.  I've got a custom object represented as a lookup field on the account record. The field is not required and in fact may be null at times. I need to do the following;

Query the custom object based on some criteria, then based on the custom object 'Id' I need to then query and get the accounts associated with the custom object.

qr = sforceClient.query("Select Id, Name, Latitude__c, Longitude__c From SFDC_65_Building__c s Where  BuildingPostalCode__c = 'xxxx'");

I am assuming I would then create some sort of an array to hold the value of the Id's returned and then in turn run an additional query based on the id's (would love to use retrieve but not possible as I don' t have the account Id) so second query would be;

qr2 = sforceClient.query("Select Id, Name From Account Where customObjectField =" +arrayValue);

I can't figure it out however. Any help much appreciated.
zachzach
Something like this?

Code:
var qr = new Array();
qr = sforceClient.query("Select Id, Name, Latitude__c, Longitude__c From SFDC_65_Building__c Where  BuildingPostalCode__c = 'xxxx'");

var tempArray = new Array();
for (var a = 0; a < qr.size; a++) {
 if (qr.records[a].get("Id") != "" && qr.records[a].get("Id") != null) {
  tempArray.push(qr.records[a].get("Id"),qr.records[a].get("Name"),qr.records[a].get("Latitude__c"),qr.records[a].get("Longitude__c"));
 }
}

var tempArray2 = new Array();
for (var a = 0; a < tempArray.length; a++) {
 var qr2 = new Array();
 qr2 = sforceClient.query("Select Id, Name From Account Where customObjectField = '"+tempArray[a][0]+"'");
 tempArray2.push(qr2.records[0].get("Id"),qr2.records[0].get("Name"));
}

 

FinTechFinTech
In conjunction with this, anyone know how you can update two objects (i.e. contact and custom object) at the same time?
zachzach
I'm pretty sure you have make separate update calls for each different object.  You can, however, update many records within the same object.  Is that what you were getting at?
-Zach

Message Edited by zach on 09-12-2006 07:41 AM

FinTechFinTech
You are right. You have to do two updates and use the id of your session to update accordingly.