Skip to content

Add a way to query multiple parent-level fields, using fewer lines of code #37

@jongpie

Description

@jongpie

With the current implementation, if you want to query multiple fields from a parent object, the code required is somewhat lengthy:

Query accountQuery = new Query(Schema.Case.SObjectType)
    .addField(new SOQL.QueryField(new List<Schema.SObjectField>{
        Schema.Case.AccountId,
        Schema.Account.AnnualRevenue
    }))
    .addField(new SOQL.QueryField(new List<Schema.SObjectField>{
        Schema.Case.AccountId,
        Schema.Account.NumberOfEmployees
    }));

System.debug(accountQuery.getQuery());
System.debug(accountQuery.getResults());

In the above example, each parent-level field has to have the chain of fields passed to a constructor for SOQL.QueryField() - it'd be nice if some of the field chain could be reused so Apex devs can write less code to get the same functionality.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions