从 Parent Object 获取孙 Object 字段值

Get Grandchild Object Field Values from Parent Object

我是 sales-force 顶点编码的新手。我有 3 个自定义 objects,Location(Parent) -> Group(child) -> Meeting(grand child) .所有这些都通过主从关系相互关联。我正在尝试从属于该位置的最早会议记录中获取 2 个字段值。

到目前为止,我设法从属于业务 Object 的最早会议记录中获取了 get 2 字段值。

public List<Meeting__c> MeetingsList2 = [SELECT Name,
GPS_Meeting_Location__Latitude__s, GPS_Meeting_Location__Longitude__s FROM    
Meeting__c WHERE Group__c =:id ORDER BY Meeting_Date__c ASC LIMIT 1];

我正在尝试获取从上述查询中获得的相同信息,但这次我想获取属于群组记录的最早会议(盛大child)记录(child) 属于 Location Record 从 Location Object (Parent object 获取 grandchild 记录字段值)

感谢任何帮助。

您可以尝试查询:

public List<Meeting__c> MeetingsList2 = [SELECT Name,
GPS_Meeting_Location__Latitude__s, GPS_Meeting_Location__Longitude__s FROM    
Meeting__c WHERE Group__c =:id AND Group__r.Location__c =:locationId 
ORDER BY Meeting_Date__c ASC LIMIT 1];

我假设,在 Group 对象中有一个指向 Location(Location__c) 的引用字段,并且您在变量 locationId[ 中有 Location 记录 ID。 仅供参考- __r 用于 traverse/access 自定义对象的父字段。