You need to sign in to do that
Don't have an account?
zeezack
Join tables?
I've managed to extract information perfectly fine for one table...its quick and dynamic. Although one of the fields it returns is an index field for another table....is there an easy way to pull out a name field from a foreign table instead of just its id?
aka
table 1
Id | Name | Primary_Account_Holder__c |
a0C20000002uh8HEAQ | MCS-CLAIM-cvcvc | 001200000dfgfdgfdAAH |
table2
Id | Name |
001200000dfgfdgfdAAH | VIVIENNE BLAKE |
How can I return it so I have
table 1
Id | Name | Primary_Account_Holder__c |
a0C20000002uh8HEAQ | MCS-CLAIM-cvcvc | VIVIENNE BLAKE |
So how would that work for this
SELECT Id, Name, Primer_id from Claim_c WHERE Name IN ('My-claim2','My-claim3452','My-claim2345','My-claim525');
now primer_id is actually the index of say Account
SELECT Id, Name from Account WHERE Name IN ('a34234234','afgbgfhgfhgf');
exactly the same way (see the docs on SOQL-R in the api docs).
SELECT Id, Name, Primer__r.name from Claim_c WHERE Name IN ('My-claim2','My-claim3452','My-claim2345','My-claim525');
How does it know to get the Name value from Account table using the Primer__r id?
how come there is no From Claim__c, Account or something?
SOQL ain't SQL.
it knows the primer__r relationship is a relationship to account (using the primer__c foreign key field), this is covered in the SOQL section of the API docs.
Sorry man. I've not got this to work.
I've caught the field
Primary_Account_Holder__c
and
placed it now as
Primary_Account_Holder__r.name
and it just puts blanks in place.
SELECT Id,Name,Primary_Account_Holder__r.name,Audit_Result__c from Claim__c WHERE Name IN ('MCS-CLAIM-34016','MCS-CLAIM-343416','MCS-CLAIM-56565016')
I can not tell, but where Primary_Account_Holder__c returned a value Primary_Account_Holder__r.name returns nothing.
Primary_Account_Holder__c would be returned as a direct value, where as the relationship is a nested structure, e.g.
<record>
<id>1111</id>
<foo>12344</foo>
</record>
vs
<record>
<id>1111</id>
<foo__r>
<name>bob</name>
</foo__r>
</record>
However you're accessing these results needs to take that into account.