Development questions
How do you write a Parent-to-Child subquery on Standard Objects (Contacts) vs Custom Objects (Employees__r)?
Use a subquery in the SELECT list with the child relationship name (plural for standard objects, __r for custom).
soql
SELECT Id, Name, (SELECT LastName, Email FROM Contacts) FROM Account
SELECT Id, Name, (SELECT Name, Salary__c FROM Employees__r) FROM Department__c
Results are nested lists: in Apex use acc.Contacts or dept.Employees__r. The relationship name comes from the lookup/master-detail field's Child Relationship Name setting.
soqlrelationshipsparent-to-child
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?