Custom queries allow you to navigate through the Salesforce object model without necessarily having to do with the original context.
The secondary object makes it possible to obtain a 2nd starting point different from the main object to allow me to search for data in another object that does not have a direct link with my main object.
You are on a main object at the level of a contact, you may need to display the list of current opportunities on the account of the contact in question.
The object model would look like this:
Recovery request in our example : SELECT AccountId FROM Contact WHERE id = {RecordId}
SELECT AccountId
AccountId is the API name of the specific field on the Contact Object. Attention, if you are on a custom lookup, the field could have been called “Account__c”
FROM Contact
We simply indicate the main object here from which we make the request
WHERE id = {RecordId}
This makes it possible to identify the account that is linked to the contact. The {RecordId} tag should be formalized precisely in this way.
Retrieval request : SELECT AccountId FROM Quote WHERE id = {RecordId}
Retrieval request : SELECT Compte__c FROM Session_Formation__c WHERE id = {RecordId}
💡 L'astuce du Support, prenez Salesforce Inspector pour trouver la requête qui permet de renvoyer le bon record qui correspond à l'objet Principal.