Development questions
How do you write a Child-to-Parent query on Standard Objects vs Custom Objects (__r)?
Use dot notation on the relationship name.
- Standard lookup: relationship name is the field name without Id, e.g.
AccountforAccountId. - Custom lookup/master-detail: field
Department__cbecomesDepartment__r.
soql
SELECT Name, Account.Name, Account.Industry FROM Contact
SELECT Name, Department__r.Name, Department__r.Manager__r.Name FROM Employee__c
Standard: Account.Name; custom: Parent__r.Name.
soqlrelationshipschild-to-parent
More Development questions
- What is an Apex Trigger in Salesforce and when should you use it over Flows?
- What is the difference between before triggers and after triggers?
- Explain all Trigger context variables (isInsert, isUpdate, isDelete, isUndelete, isBefore, isAfter, isExecuting, size, operationType).
- What is the difference between Trigger.new and Trigger.old?
- In which trigger events are Trigger.new and Trigger.newMap available?
- In which trigger events are Trigger.old and Trigger.oldMap available?