Best Practices for PromotionPushRemoteActionExtension

This topic focuses on different types of Apex implementations to push multiple parent promotions.

For more information, see PromotionPushRemoteActionExtension Class. The type of Apex implementations are:

  • Sync Apex Snippet (legacy mode only)
  • Queueable (both new and legacy modes)
  • Future Method (new mode only)
  • Apex Batch Class (new mode only)

An Apex code snippet is provided for each Apex class.

Legacy Mode

In Summer ‘25 or earlier releases, PromotionPushRemoteActionExtension Class used only Apex Flex Queue to push promotions. This method of using Apex Flex Queue is referred to as Legacy Mode in this topic. This method continues to be available in future releases.

New Mode

In Winter ‘26 or later releases, a new method to push promotions using the PromotionPushRemoteActionExtension Apex class is introduced. To enable the new method, the PushPromotionExecutionMode system setting must be set to OffPlatform.

Sync Apex Snippet

This approach of Apex implementation uses the legacy mode to push promotions using the PromotionPushRemoteActionExtension Apex class. It demonstrates how to push multiple parent promotions from one synchronous Apex execution context.

1List<String> promotionIds = new List<String>{
2    '<PARENTPROMOID01',
3    '<PARENTPROMOID02'
4    };
5
6for (String promotionId : promotionIds) {
7    String readParams = '{"promotionId":"' + promotionId.trim() + '"}';
8    String txid = UUID.randomUUID().toString();
9    cgcloud_dev.PromotionPushRemoteActionExtension.pushBOPromotion(txid, readParams);
10}

Queueable

This approach of Apex implementation can use either the legacy mode or the new mode to push promotions using the PromotionPushRemoteActionExtension Apex class. It demonstrates how to push multiple parent promotions with a Queueable implementation. It requires implementation of an Apex class implementing Queueable and AllowsCallouts interfaces and an Apex code which schedules the queueable jobs (one job per parent promotion to push).

Implement Queueable and AllowsCallouts
1public class SchedulePromotionPushQueueable implements Queueable, Database.AllowsCallouts {
2  public String promotionId { get; set; }
3
4  public void execute(QueueableContext qc) {
5       String readParams = '{"promotionId":"' + this.promotionId + '"}';
6       String txid = cgcloud_dev.TransactionHandler.getTransactionIdentifier();
7       cgcloud_dev.PromotionPushRemoteActionExtension.pushBOPromotion(txid, readParams);
8  }
9}
Scheduling Apex Snippet
1List<String> promotionIds = new List<String>{
2    '<PARENTPROMOID01',
3    '<PARENTPROMOID02'
4    };
5
6for (String promotionId : promotionIds) {
7  SchedulePromotionPushQueueable q = new SchedulePromotionPushQueueable();
8  q.promotionId = promotionId.trim();
9  System.enqueueJob(q);
10}

Future Method

This approach of Apex implementation uses the new mode to push promotions using the PromotionPushRemoteActionExtension Apex class. It demonstrates how to push multiple parent promotions with a Future annotated method implementation. Each call to the future annotated method schedules one parent promotion.

1public class SchedulePromotionPushFuture {
2  public List<String> promotionIds { get; set; }
3
4  public void execute() {
5    for (String promotionId : this.promotionIds) {
6      SchedulePromotionPushFuture.schedulePushPromotion(promotionId.trim());
7    }
8  }
9  
10  @future(callout=true)
11  static public void schedulePushPromotion(String promotionId) {
12       String readParams = '{"promotionId":"' + promotionId + '"}';
13       String txid = cgcloud_dev.TransactionHandler.getTransactionIdentifier();
14       cgcloud_dev.PromotionPushRemoteActionExtension.pushBOPromotion(txid, readParams);
15  }
16}
Scheduling Apex Snippet
1SchedulePromotionPushFuture futureClass = new SchedulePromotionPushFuture();
2futureClass.promotionIds = new List<String>{
3    '<PARENTPROMOID01',
4    '<PARENTPROMOID02'
5    };
6futureClass.execute();

Apex Batch Class

This approach of Apex implementation uses the new mode to push promotions using the PromotionPushRemoteActionExtension Apex class. It demonstrates how to push multiple parent promotions with a Batchable implementation. It requires implementation of an Apex class implementing Batchable and AllowsCallouts interfaces and an Apex code which schedules the batch job. The execute method of the batch job schedules one parent promotion push per call. It’s required to use a batch size of 1 when scheduling the batch job.

1public class SchedulePromotionPushBatch implements Database.Batchable<String>, Database.AllowsCallouts, Database.Stateful {
2
3  public List<String> promotionIds { get; set; }
4
5  public Iterable<String> start(Database.BatchableContext bc
6) {
7    return this.promotionIds;
8  }
9
10  public void execute(Database.BatchableContext bc, List<String> scope) {
11       String readParams = '{"promotionId":"' + scope.get(0).trim() + '"}';
12       String txid = cgcloud_dev.TransactionHandler.getTransactionIdentifier();
13       cgcloud_dev.PromotionPushRemoteActionExtension.pushBOPromotion(txid, readParams);
14  }
15
16  public void finish(Database.BatchableContext bc) {
17  }
18}
Scheduling Apex Snippet
1SchedulePromotionPushBatch batchClass = new SchedulePromotionPushBatch();
2batchClass.promotionIds = new List<String>{
3    '<PARENTPROMOID01',
4    '<PARENTPROMOID02'
5    };
6Database.executeBatch(batchClass, 1);