Enable the global editability and visibility of a promotion or tactic by modifying its
EARights.
- Log in to your Salesforce org, and go to Developer Console.
-
Create a global Apex class that implements the System.Callable interface.
-
Override the global call method that has these
parameters.
- action: String. The behavior for the method to exhibit.
- params: Map<String,Object>. Arguments to be used by the specified action. The object is of type List<EARightsAccess>. Each EARightsAccess instance has properties that you can modify. For information on this class, see EARightsAccess Class Reference.
Here’s the Apex class structure for the promotion and tactic EARights customization.
global class <Your Callable Apex Class> implements System.Callable { global Object call(String action, Map<String, Object> args) { // Read Transaction Id String txId = (String) args.get('txId'); // Get the Promotion Id Id promotionId = args.get('promotionId'); // Get the Promotion EARigths List<cgcloud.EARightsAccess> promotionRights = (List<cgcloud.EARightsAccess>) args.get('EARights'); // Your custom logic goes here } }global class <Your Callable Apex Class> implements System.Callable { global Object call(String action, Map<String, Object> args) { // Read Transaction Id String txId = (String) args.get('txId'); // Get the Promotion Id Id promotionId = args.get('promotionId'); // Get the Tactic EARigths List<cgcloud.EARightsAccess> tacticRights = (List<cgcloud.EARightsAccess>) args.get('EARights'); // Your custom logic goes here } } -
To modify the EARights associated with a promotion or tactic, edit the properties of
the associated EARightsAccess instance in the
respective Apex class. For a list of modifiable promotion and tactic EARights, see Modifiable Promotion and Tactic EARights.
Here’s a sample Apex class that modifies the EARights of the promotion edit button associated with an existing promotion.
global class MyEditAccessRightsHook implements System.Callable { global Object call(String action, Map<String, Object> args) { // Read Transaction Id String txId = (String) args.get('txId'); // Get the Promotion Id Id promotionId = args.get('promotionId'); // Get the EARigths List<cgcloud.EARightsAccess> promotionRights = (List<cgcloud.EARightsAccess>) args.get('EARights'); // Get the Promotion Template name List<cgcloud__Promotion__c> promos = [ SELECT cgcloud__Promotion_Template__r.Name FROM cgcloud__Promotion__c WHERE Id = :promotionId LIMIT 1 ]; // Check if its the target template Boolean isNoTactics = promos[0].cgcloud__Promotion_Template__r.Name == 'No Tactics'; // Search the related EARightsAccess instance for (cgcloud.EARightsAccess acl : promotionRights) { if (acl.Name == 'PROMOTION_EDIT_BUTTON' && isNoTactics) { acl.Visible = false; acl.Editable = false; } } } } - From Setup, in the Quick Find box, enter Custom Metadata Types, and then expand Custom Metadata Types.
- On the CGCloud Process Customization row, click Manage Records.
-
Click New, complete these fields, and then save your work.
For promotion EARights customization, fill these details.
- Label: TPM_Promotion_EARightsAccess_Promotion
- DeveloperName: TPM_Promotion_EARightsAccess_Promotion
- Class: <Your Callable Apex Class for modifying the promotion EARights>
- Method: save
- Enabled: Select the checkbox.
For tactic EARights customization, fill these details.
- Label: TPM_Promotion_EARightsAccess_Tactic
- DeveloperName: TPM_Promotion_EARightsAccess_Tactic
- Class: <Your Callable Apex Class for modifyng the tactic EARights>
- Method: save
- Enabled: Select the checkbox.
The Apex customization hook is enabled. The call
method modifies the EARights of an existing promotion, or tactic based on your custom
logic.