---
schema_version: "1"
id: ade2a67a3042fd58f26b6d6e2906b2adfcf4e9a5e8742f420c6abfc6b3915f9b
title: Promotion and Tactic Transfer Customization Use Cases
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/retail_api/tactic_transfer_apex_save_customization.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/tactic_transfer_apex_save_customization.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: fd7508da43c1263912deaf633c2fa1113b9c41020c3b4e74b714c86440a98733
description: This section provides different Apex customization use cases for the promotion and tactic transfer process.
---
# Promotion and Tactic Transfer Customization Use Cases

This section provides different Apex customization use cases for the promotion and tactic transfer process.

## Change a managed package sObject field value

Here’s a sample Apex class that modifies the date field of a tactic.

global class TacticTransferSaveCust implements System.Callable {
    global Object call(String action, Map<String, Object> params) {
    List<cgcloud.RE\_TacticTransfer> tacticTransferWrapper = (List<cgcloud.RE\_TacticTransfer>) params.get('tacticTransfer');
    cgcloud\_\_Tactic\_\_c record = (cgcloud\_\_Tactic\_\_c) tacticTransferWrapper\[0\].getTactic().getRecord();

    if (record.cgcloud\_\_Date\_Thru\_\_c != null) {
    record.cgcloud\_\_Date\_Thru\_\_c = record.cgcloud\_\_Date\_Thru\_\_c.addDays(1);
    }

    return tacticTransferWrapper;
 }
}

Here’s a sample Apex class that modifies the slogan field of a promotion.

global class PromotionTransferSaveCust implements System.Callable {
    global Object call(String action, Map<String, Object> params) {
String SAVE\_HOOK\_SUFFIX = ' Slogan hook ';
// Get the RE\_PromotionTransfer instance
List<cgcloud.RE\_PromotionTransfer> promotionTransferWrapperList = (List<cgcloud.RE\_PromotionTransfer>) params.get('promotionTransfer');
        
for(cgcloud.RE\_PromotionTransfer promotionTransferWrapper : promotionTransferWrapperList) {
    cgcloud\_\_Promotion\_\_c record = (cgcloud\_\_Promotion\_\_c) promotionTransferWrapper.getPromotion().getRecord();

    if (record.cgcloud\_\_Slogan\_Language\_1\_\_c != null) {
        record.cgcloud\_\_Slogan\_Language\_1\_\_c =
        record.cgcloud\_\_Slogan\_Language\_1\_\_c + SAVE\_HOOK\_SUFFIX;
    }
}

return promotionTransferWrapperList;
}
}

## Delete a managed package sObject record

Here’s a sample Apex class that deletes the first tactic from the list of tactics.

global class TacticTransferSaveCust implements System.Callable {
    global Object call(String action, Map<String, Object> params) {
// Get the RE\_TacticTransfer instance
   List<cgcloud.RE\_TacticTransfer> tacticTransferWrapper = (List<cgcloud.RE\_TacticTransfer>) params.get('tacticTransfer');

// Delete the first Tactic\_\_c SObject
   cgcloud.RE\_TacticTransfer.Record tacticRecordWrapper = tacticTransferWrapper\[0\].getTactics()\[0\];
    if (!tacticRecordWrapper.isDeleted())
    {
       // We can also check if the record is new with isNew()
      tacticRecordWrapper.setIsDeleted(true);
    }
    return tacticTransferWrapper;
 }
}

Here’s a sample Apex class that deletes the first promotion from the list of promotions.

global class PromotionTransferSaveCust implements System.Callable {
    global Object call(String action, Map<String, Object> params) {
// Get the List of RE\_PromotionTransfer instances
List<cgcloud.RE\_PromotionTransfer> promotionTransferWrapperList = (List<cgcloud.RE\_PromotionTransfer>) params.get('promotionTransfer');

// Delete the first Promotion\_\_c sObject
cgcloud.RE\_PromotionTransfer.Record promotionRecord = promotionTransferWrapper\[0\].getPromotion();
if (!promotionRecord.isDeleted())
{ 
     // We can also check if the record is new with isNew()
    promotionRecord.setIsDeleted(true);
}
    return promotionTransferWrapperList;
 }
}

## Add a custom sObject

Here’s a sample Apex class that adds additional tactic sObject records to a planned promotion that is saved.

global class TacticTransferSaveCust implements System.Callable {
    global Object call(String action, Map<String, Object> params) {
     List<cgcloud.RE\_TacticTransfer> tacticTransferWrapper = (List<cgcloud.RE\_TacticTransfer>) params.get('tacticTransfer');
     for (Integer count = 0; count < 2; count++) {
       cgcloud\_\_Tactic\_\_c newTactic = new cgcloud\_\_Tactic\_\_c();
       newTactic.cgcloud\_\_Tactic\_Template\_\_c = 'a3A8D000000RFbnUAG';
       newTactic.cgcloud\_\_Date\_From\_\_c = Date.newInstance(2023, 9, 9);
       newTactic.cgcloud\_\_Date\_Thru\_\_c = Date.newInstance(2023, 9, 12);
       newTactic.RecordTypeId = '0128D000002MRKIQA4';
       newTactic.cgcloud\_\_Promotion\_\_c = 'a2Y8D000000g4kZUAQ';
       tacticTransferWrapper.add(new cgcloud.RE\_TacticTransfer(newTactic));
   }
  return tacticTransferWrapper;
 }
}

Here’s a sample Apex class that adds a promotion sObject record during the promotion save process.

global class PromotionTransferSaveCust implements System.Callable {
    global Object call(String action, Map<String, Object> params) {
// Get the List of RE\_PromotionTransfer instance
List<cgcloud.RE\_PromotionTransfer> promotionTransferWrapperList = (List<cgcloud.RE\_PromotionTransfer>) params.get('promotionTransfer');

//Get the first Promotion Record from the wrapper
cgcloud\_\_Promotion\_\_c record = (cgcloud\_\_Promotion\_\_c) promotionTransferWrapper\[0\].getPromotion().getRecord();

List<cgcloud\_\_Promotion\_\_c> promotionList = new List<cgcloud\_\_Promotion\_\_c>();

for (Integer count = 0; count < 1; count++) {
    cgcloud\_\_Promotion\_\_c newPromotion = new cgcloud\_\_Promotion\_\_c();
    newPromotion.cgcloud\_\_Slogan\_Language\_1\_\_c = record.cgcloud\_\_Slogan\_Language\_1\_\_c + count;
    promotionList.add(newPromotion);
    newPromotion.cgcloud\_\_Promotion\_Template\_\_c = 'a2X8D0000003NHQUA2'; //Update the new promotion with the target Promotion Template
    newPromotion.cgcloud\_\_Date\_From\_\_c = Date.newInstance(2023, 9, 9);
    newPromotion.cgcloud\_\_Date\_Thru\_\_c = Date.newInstance(2023, 9, 12);
    newPromotion.RecordTypeId = '0128D000002MRKEQA4'; //Update the new promotion with the correct Record Type ID
    promotionTransferWrapper.add(new cgcloud.RE\_PromotionTransfer(newPromotion));
}

return promotionTransferWrapper; 
}
}

![Note](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/images/icon_note.png)

#### Note

The TPM\_Promotion class ensures that all the promotion-related sObjects are committed in an all-or-none fashion while encapsulating all operations in a transaction.

## Get the tactic products linked to a tactic, and perform customization on the tactic products

Here’s a sample Apex class that gets all the products linked to a tactic and deletes the first product in the list.

global class TacticTransferSaveCust implements System.Callable {
    global Object call(String action, Map<String, Object> params) {
     List<cgcloud.RE\_TacticTransfer> tacticProductTransferWrapper = (List<cgcloud.RE\_TacticTransfer>) params.get('tacticTransfer');
     List<cgcloud.RE\_TacticTransfer.Record> records = (List<cgcloud.RE\_TacticTransfer.Record>) tacticProductTransferWrapper\[0\].getTacticProducts(); 
     records\[0\].setIsDeleted(true);
     return tacticProductTransferWrapper;
 }
}

## Add new tactic products to the existing managed package or new tactic records

Here’s a sample Apex class that adds a product to a specific tactic.

global class TacticTransferSaveCust implements System.Callable {
    global Object call(String action, Map<String, Object> params) {
    List<cgcloud.RE\_TacticTransfer> tacticTransferWrapper = (List<cgcloud.RE\_TacticTransfer>) params.get('tacticTransfer');
    List<cgcloud.RE\_TacticTransfer.Record> records = (List<cgcloud.RE\_TacticTransfer.Record>) tacticTransferWrapper\[0\].getTacticProducts();
    if(records.size()>0){
      cgcloud\_\_Tactic\_Product\_\_c newTacticProduct = new cgcloud\_\_Tactic\_Product\_\_c();
      newTacticProduct.cgcloud\_\_Tactic\_\_c = tacticTransferWrapper\[0\].getTactic().getId();
      newTacticProduct.cgcloud\_\_Product\_\_c='01t8D000003vc4aQAA';
      tacticTransferWrapper\[0\].addTacticProduct(newTacticProduct);
    }
  return tacticTransferWrapper;
  }
}