简体   繁体   中英

How to access a lookup field through SOQL in salesforce?

3 Standard Objects: A, B, C

  1. A has a field f1 lookup with B object.
  2. B has a field f2 lookup with C object.
  3. C has a field f3 which is a text.

How to access f3 field value through Object A?

Assuming A, B and C are standard objects, and f1, f2, f3 are standard fields; and all of them are API names, your SOQL query would look something like:

SELECT f1.f2.f3 FROM A

If A, B and C are custom objects, and f1, f2 and f3 are custom fields; and again all of them are API names, it would look like:

SELECT f1__r.f2__r.f3__c FROM A__c

Also remember to add some kind of WHERE or LIMIT clause to avoid hitting governor limits .

More info on SOQL relationships.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM