Customize the Tactic Transfer Process
To modify the tactic details related to the promotion being transferred, create a
callable Apex class as a customization hook.
- 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<RE_TacticTransfer>. The RE_TacticTransfer class exposes methods to access the promotion and its tactic or tactic products. For a list of all the exposed methods, see RE_TacticTransfer Class Reference.
Here’s the Apex class structure.
1global class < Your Callable APEX Class > implements System.Callable { 2 3 global Object call(String action, Map < String, Object > params) { 4 // Get the RE_TacticTransfer instances from the arguments 5 List < cgcloud.RE_TacticTransfer > tacticTransferWrapper = (List < cgcloud.RE_TacticTransfer > ) params.get('tacticTransfer'); 6 // Your custom logic goes here 7 return tacticTransferWrapper; 8 } 9} -
To modify the tactic or tactic product fields, use the methods exposed by the RE_TacticTransfer class.
Add your customizations in the Apex class to:
- Create additional tactic records.
- Modify and delete existing tactic records.
Here’s a sample Apex class that adds additional tactic sObject records to a planned promotion that’s saved.1global class TacticTransferSaveCust implements System.Callable { 2 3 global Object call(String action, Map < String, Object > params) { 4 // Get the RE_TacticTransfer instances from the arguments 5 List < cgcloud.RE_TacticTransfer > tacticTransferWrapper = (List < cgcloud.RE_TacticTransfer > ) params.get('tacticTransfer'); 6 for (Integer count = 0; count < 2; count++) { 7 cgcloud__Tactic__c newTactic = new cgcloud__Tactic__c(); 8 newTactic.cgcloud__Tactic_Template__c = 'a3A8D000000RFbnUAG'; 9 newTactic.cgcloud__Date_From__c = Date.newInstance(2023, 9, 9); 10 newTactic.cgcloud__Date_Thru__c = Date.newInstance(2023, 9, 12); 11 newTactic.RecordTypeId = '0128D000002MRKIQA4'; 12 newTactic.cgcloud__Promotion__c = 'a2Y8D000000g4kZUAQ'; 13 tacticTransferWrapper.add(new cgcloud.RE_TacticTransfer(newTactic)); 14 } 15 return tacticTransferWrapper; 16 } 17}For use cases related to the promotion and tactic transfer process customization, see Promotion and Tactic Transfer Customization Use Cases. - 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, fill the following details, and then save your
work.
- Label: RE_Tactic_Transfer_Save
- DeveloperName: RE_Tactic_Transfer_Save
- Class: <Your Callable APEX Class>
- Method: save
- Enabled: Select the checkbox.
The Apex customization hook is enabled. When a planned promotion is saved in TPM, the
call method modifies the tactic or tactic product
details related to the promotion based on your custom logic before transferring it to
RE.