Use Promotion Business Objects API
Promotion Business Object API can be accessed through REST API, Aura Components, and
Lightning Web Component.
REST API
To process records with Promotion BO API, you need to use the provided REST endpoints in the defined process:
- Initialize a transaction with the number of records to process:
-
URL: <ORG INSTANCE>/services/apexrest/cgcloud/promotions/initialize
METHOD: POST
PAYLOAD:1{ 2 “nrOfItems” : 500, // Number of records for the transaction 3 “salesOrg”: “0001” // Sales Org of the records 4} - This request returns an import ID that should be passed to every subsequent requests.
-
- Queue the records to process in blocks of 50 records.
-
URL: <ORG INSTANCE>/services/apexrest/cgcloud/promotions/ingest
METHOD: POST
PAYLOAD:1{ 2 “importId” : ”3121b14e-f370-4c1b-8b09-b9323ea38216”, // Import Id received from previous request. 3 “workflow”: “create” // Workflow name to execute 4 “salesOrg” : “0001” // Sales org 5 “promotions”: [...] // Array of up to 50 records where each record represents a Promotion. 6} - Each call can contain up to 50 records.
- You can send as many requests to fill the “nrOfItems” defined in the request sent to initialize a transaction.
-
- Monitor the process.
-
URL: <ORG INSTANCE>/services/apexrest/cgcloud/promotions/status?importId=<import Id>
METHOD: GET
- This returns the status for all records part of the transaction.
-
Aura
You can send requests to the Promotion BO API from an Aura Component.
Component markup
1...
2<cgcloud:PromotionBoApi aura:id="bo-api"></cgcloud:PromotionBoApi>
3...Component controller
1...
2const boApi = component.find("bo-api");
3
4// Receives a workflow name and a list of promotion objects
5// Supports up to 10000 records
6boApi.queue(workflowName, promotionList)
7.then((result) => {
8 // Resolves after the promotions have been enqueued for BO API processing
9 // returns the import id
10 // Promotions are processed asynchronously
11});
12
13// Receives a workflow name and a single promotion
14boApi.process(workflowName, promotion)
15.then((result) => {
16 // Resolves after the promotion has been processed and committed to database (synchronous)
17 // Result contains the processed promotion id
18});
19...Lightning Web Component
Component
controller
1import { process, queue } from 'cgcloud/tpmBoApi';
2
3...
4// Receives a workflow name and a list of promotion objects
5// Supports up to 10000 records
6queue('Promotion', workflowName, promotionList)
7.then((result) => {
8 // Resolves after the promotions have been enqueued for BO API processing
9 // returns the import id
10 // Promotions are processed asynchronously
11});
12
13// Receives a workflow name and a single promotion
14process('Promotion', workflowName, promotion)
15.then((result) => {
16 // Resolves after the promotion has been processed and committed to database (synchronous)
17 // Result contains the processed promotion id
18});
19...