Skip to content

Instantly share code, notes, and snippets.

@gitmatheus
Last active March 25, 2022 01:28
Show Gist options
  • Save gitmatheus/a9dc6cf183893d6b482ec3b43045a4f6 to your computer and use it in GitHub Desktop.
Save gitmatheus/a9dc6cf183893d6b482ec3b43045a4f6 to your computer and use it in GitHub Desktop.
// Snippet from the AccountTriggerHandler
...
// If the mock data is not being used
// creates new instances of the real deal
public AccountTriggerHandler() {
this(new DataLayer(), new FieldReader());
}
// Child_Accounts__r is a nonwritable child relationship
// Uses the field reader to retrieve the list of child records:
List<Account> childRecords =
fieldReader.getFieldRecords(parentAndChildAccount, 'Child_Accounts__r');
// Updates the field Latest Child URL with the value from External_URL__c
// External_URL__c is a formula field (nonwritable string)
newRecord.Latest_Child_URL__c =
(String)fieldReader.getFieldValue(latestChild, 'External_URL__c');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment