This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger <trigger_name> on <Object_Name> (<event_list>) { | |
// Trigger Logic | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger AccountTrigger on Account (after delete, after insert, after undelete, after update, before delete, before insert, before update) { | |
new AccountTriggerHandler().run(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class AccountTriggerHandler extends TriggerHandlerBase { | |
protected override void beforeInsert(List<Sobject> newRecords) { | |
List<Account> newAccounts = (List<Account>) newRecords; | |
} | |
protected override void beforeUpdate(Map<Id, Sobject> oldRecordsMap, Map<Id, Sobject> newRecordsMap) { | |
Map<Id, Account> oldAccountsMap = (Map<Id, Account>) oldRecordsMap; | |
Map<Id, Account> newAccountsMap = (Map<Id, Account>) newRecordsMap; | |
// Do something with the Account records. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public virtual with sharing class TriggerHandlerBase { | |
public void run() { | |
// dispatch to the correct handler method | |
if(Trigger.isBefore) { | |
if (Trigger.isInsert) { | |
this.beforeInsert(Trigger.New); | |
} | |
else if(Trigger.isUpdate) { | |
this.beforeUpdate(Trigger.oldMap, Trigger.newMap); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Id firstId = 'a0a5B000002XgIoQAK'; | |
List<Id> ids = new List<Id>{ firstId }; | |
Id sameId = 'a0a5B000002XgIoQAK'; | |
// false... wtf? | |
system.debug(' list of ids contains same id? ' + ids.contains(sameId)); | |
Set<Id> setOfIds = new Set<Id>{ firstId }; | |
// true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<c:PageLayoutRecordDislay RecordId="{! <record_id_here> }" PageLayoutName="<page_layout_api_name>" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest | |
public with sharing class PageLayoutRecordDisplayControllerTest { | |
@isTest | |
static void getPageLayoutMetadata_emptyPageLayoutName_expectEmptyPageLayoutTest() { | |
PageLayoutRecordDisplayController.PageLayout pageLayout = | |
PageLayoutRecordDisplayController.getPageLayoutMetadata(''); | |
assertEmptyPageLayout(pageLayout); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PageLayoutRecordDisplayController { | |
@AuraEnabled | |
public static PageLayout getPageLayoutMetadata(String pageLayoutName) { | |
List<String> componentNameList = new List<String>{pageLayoutName}; | |
if (String.isBlank(pageLayoutName)) { | |
return new PageLayout(); | |
} | |
List<Metadata.Metadata> layouts = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<design:component > | |
<design:attribute name="PageLayoutName" label="Page Layout Name" description="The API name of the page layout." /> | |
<design:attribute name="recordId" label="Record Id" description="The id of the record." /> | |
<design:attribute name="sObjectName" label="Object Name" description="The Object's API name. This is required if not used on a record page." /> | |
</design:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
retrievePageLayout : function(component, helper) { | |
var action = component.get("c.getPageLayoutMetadata"); | |
var pageLayoutName = component.get("v.PageLayoutName"); | |
console.log("pageLayoutName: " + pageLayoutName); | |
var actionParams = { | |
"pageLayoutName" : pageLayoutName | |
}; |