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
- 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
- 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 controller
... const boApi = component.find("bo-api"); // Receives a workflow name and a list of promotion objects // Supports up to 10000 records boApi.queue(workflowName, promotionList) .then((result) => { // Resolves after the promotions have been enqueued for BO API processing // returns the import id // Promotions are processed asynchronously }); // Receives a workflow name and a single promotion boApi.process(workflowName, promotion) .then((result) => { // Resolves after the promotion has been processed and committed to database (synchronous) // Result contains the processed promotion id }); ...
Lightning Web Component
Component
controller
import { process, queue } from 'cgcloud/tpmBoApi'; ... // Receives a workflow name and a list of promotion objects // Supports up to 10000 records queue('Promotion', workflowName, promotionList) .then((result) => { // Resolves after the promotions have been enqueued for BO API processing // returns the import id // Promotions are processed asynchronously }); // Receives a workflow name and a single promotion process('Promotion', workflowName, promotion) .then((result) => { // Resolves after the promotion has been processed and committed to database (synchronous) // Result contains the processed promotion id }); ...