Newer Version Available
Customize the Promotion Transfer Process
To modify the promotion details 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_PromotionTransfer>. The RE_PromotionTransfer class exposes methods to access the promotion. For a list of all the exposed methods, see RE_PromotionTransfer 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_PromotionTransfer instances from the arguments 5 List<cgcloud.RE_PromotionTransfer> promotionTransferWrapper = (List<cgcloud.RE_PromotionTransfer>) params.get('promotionTransfer'); 6 // Your custom logic goes here 7 return promotionTransferWrapper; 8 } 9} -
To modify the promotion fields, use the methods exposed by the RE_PromotionTransfer class.
Add your customizations in the Apex class to:
- Create promotion records.
- Modify and delete existing promotion records.
Here’s a sample Apex class that adds a new promotion sObject record during the promotion save process.1global class PromotionTransferSaveCust implements System.Callable { 2 global Object call(String action, Map < String, Object > params) { 3 // Get the List of RE_PromotionTransfer instances 4 List < cgcloud.RE_PromotionTransfer > promotionTransferWrapperList = (List < cgcloud.RE_PromotionTransfer > ) params.get('promotionTransfer'); 5 //Get the first Promotion Record from the wrapper 6 cgcloud__Promotion__c record = (cgcloud__Promotion__c) promotionTransferWrapper[0].getPromotion().getRecord(); 7 8 List < cgcloud__Promotion__c > promotionList = new List < cgcloud__Promotion__c > (); 9 10 for (Integer count = 0; count < 1; count++) { 11 cgcloud__Promotion__c newPromotion = new cgcloud__Promotion__c(); 12 newPromotion.cgcloud__Slogan_Language_1__c = record.cgcloud__Slogan_Language_1__c + count; 13 promotionList.add(newPromotion); 14 newPromotion.cgcloud__Promotion_Template__c = 'a2X8D0000003NHQUA2'; //Update the new promotion with the target Promotion Template 15 newPromotion.cgcloud__Date_From__c = Date.newInstance(2023, 9, 9); 16 newPromotion.cgcloud__Date_Thru__c = Date.newInstance(2023, 9, 12); 17 newPromotion.RecordTypeId = '0128D000002MRKEQA4'; //Update the new promotion with the correct Record Type ID 18 promotionTransferWrapper.add(new cgcloud.RE_PromotionTransfer(newPromotion)); 19 } 20 return promotionTransferWrapper; 21 } 22}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 in these details, and then save your work.
- Label: RE_Promotion_Transfer_Save
- DeveloperName: RE_Promotion_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 existing promotion. Or it adds
a promotion record based on your custom logic before transferring it to RE, where the
promotion becomes sellable.