You are here:
Add Products to the Enterprise Cart Invocable Action
Add multiple products to a quote or order asynchronously, including product attributes and only the members or groups you select.
Required Editions
| Available in: Lightning Experience |
| Available in: Enterprise, Unlimited, and Developer Editions |
Available from the Salesforce REST Actions API, Flow Builder, and OmniStudio in API version 68.0 and later, this action queues a batch job that adds products to a quote or order. The action immediately returns a batch job ID for tracking the asynchronous operation.
Input Values
| Parameter | Required | Description | Data Type |
|---|---|---|---|
| cartId | Yes | The ID of the quote or order to add products to. | String |
| cartType | Yes | The type of cart. Valid values are Quote and Order. |
String |
| products | Yes | A JSON array of product objects. Each object requires pricebookEntryId and can include productCode, memberIds, groupIds, and attributes. Each attribute object contains productCode, attributeCode, and value. |
String (JSON array) |
| skipInvalidProducts | No | A Boolean value that indicates whether to skip adding invalid products to the cart. If not specified, the default value is true. |
Boolean |
Output Values
| Parameter | Description | Data Type |
|---|---|---|
| success | A Boolean value that indicates whether the batch job was queued. | Boolean |
| message | A status message that describes the operation. | String |
| batchJobId | The batch job ID for tracking the asynchronous operation. | String |
| error | An error message if the operation couldn't be queued. | String |
Usage
Use this action to add several products to a quote or order in one asynchronous operation.
For each product, specify a price book entry. You can also specify attributes and associate the product with quote members or groups.
Poll the AsyncApexJob record by using batchJobId to monitor processing.
Considerations
- The action supports asynchronous processing only.
- The
productsinput must be a valid JSON array encoded as a string when the REST Actions API is used. - Each product object requires
pricebookEntryId. - The running user must have access to the cart.
- Business and validation failures are returned in
outputValues.error.
Example Input
{
"inputs": [
{
"cartId": "0Q0XXXXXXXXXXXXXXX",
"cartType": "Quote",
"products": [
{
"pricebookEntryId": "01uXXXXXXXXXXXXXXX",
"productCode": "BROADBAND",
"memberIds": ["a0XXXXXXXXXXXXXXXX"],
"attributes": [
{ "productCode": "BROADBAND", "attributeCode": "SPEED", "value": "1Gbps" }
]
}
]
}
]
}Example Output
[
{
"actionName": "vlocity_cmt__B2BCmexAddProductsToECInvocable",
"isSuccess": true,
"errors": null,
"outputValues": {
"success": true,
"message": "Add products to enterprise cart initiated successfully.",
"batchJobId": "707XXXXXXXXXXXXXXX",
"error": null
}
}
]Error Handling
Check outputValues.error to determine whether the request was queued. Business and validation failures don't populate the Actions API errors array.
The action returns an error when products contains invalid JSON:
Invalid JSON in products: <detail>The action returns the following error when products isn't an array:
products must be a JSON array