- 
                Notifications
    
You must be signed in to change notification settings  - Fork 0
 
The Soql.ParentField Class
        Jason Siders edited this page Jul 4, 2025 
        ·
        5 revisions
      
    Use this class to add parent (or multiple-grandparent) object fields to your query without using Strings, ex., Account.Owner.Profile.Name. This approach enforces referential integrity, and helps avoid runtime failures (if for example, the field doesn't exist or is misspelled).
This class implements Soql.Selectable, and therefore can be used in conjunction with the addSelect builder method:
SELECT Id, Account.Owner.Name FROM OpportunitySoql.ParentField field = new Soql.ParentField(
  Opportunity.AccountId,
  Account.OwnerId,
  User.Name
);
Soql query = DatabaseLayer.Soql.newQuery(Opportunity.SObjectType)
  ?.addSelect(field)
  ?.toSoql();Accepts a List<SObjectField>, or up to six separate SObjectField arguments (up to five relationship fields, plus the actual field to be returned in the query). Each argument represents a field in the sequential "chain" of relationships leading from the FROM object to the ultimate field to be queried.
Soql.ParentField(List<SObjectField> relationshipFieldChain)Soql.ParentField(SObjectField field1, [field2, field3, field4, field5, field6])
- Generating Test Records
 - Dml
 - Soql
 - Cmdt
 - Plugins
 
- DatabaseLayer
 - Dml
 - MockDml
 - MockRecord
 - Cmdt
 - MockCmdt
 - MockSoql
 - 
Soql
- Soql.AggregateResult
 - Soql.Aggregation
 - Soql.Binder
 - Soql.Builder
 - Soql.Condition
 - Soql.ConditionalLogic
 - Soql.Criteria
 - Soql.Cursor
 - Soql.Function
 - Soql.InnerQuery
 - Soql.InvalidParameterValueException
 - Soql.LogicType
 - Soql.NullOrder
 - Soql.Operation
 - Soql.Operator
 - Soql.ParentField
 - Soql.PreAndPostProcessor
 - Soql.QueryLocator
 - Soql.Request
 - Soql.Scope
 - Soql.Selectable
 - Soql.SortDirection
 - Soql.SortOrder
 - Soql.Subquery
 - Soql.TypeOf
 - Soql.Usage
 - Soql.WhenClause