Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jongpie opened this issue Jan 16, 2023 · 0 comments

Comments

@jongpie
Copy link
Owner

jongpie commented Jan 16, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant