Skip to content
Discussion options

You must be logged in to vote

Hi @maxner-sdocs ,

Great question!

I would suggest https://soql.beyondthecloud.dev/api/soql#with-related-field1---field5

List<Opportunity> opps = SOQL.of(Opportunity.SObjectType)
    .with(Opportunity.Name)
    .with(Opportunity.Account.getDescribe().getRelationshipName(), Account.Name)
    .with('Account.CreatedBy', User.Name)
    .toList();

Why in this way?
It's impossible to get multiple levels of relationship with getRelationshipName().

SOQL Lib use relationships name as a String, and fields as SObjectField so at least target fields are stored as reference.
Relationship Name: 'Account.CreatedBy',
Target Field: User.Name

SOQL Lib will do something like that:
Relationship Name + SObject…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@maxner-sdocs
Comment options

@pgajek2
Comment options

@maxner-sdocs
Comment options

Answer selected by maxner-sdocs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
documentation Improvements or additions to documentation
2 participants