Delete Discount from a Cart
The deleteCartDiscount is a core transactional API in Salesforce Industries CPQ that removes a discount (Account / Contract / Order Type) from a cart, then automatically re-prices the cart and re-validates it against cardinality rules.
This functionality is available only through the remote Apex entry point CpqAppHandler.deleteCartDiscount and is not exposed via any REST endpoint.
Functional Summary
- Removes the discount line(s) referenced by the input
idparameter from the cart identified bycartId. - Cascades re‑price & cardinality validation – invoke the pricing pipeline and the validation pipeline so recurring, one‑off and usage charges remain accurate and bundle constraints stay intact.
- Returns a structured
actionsmap (itempricesupdated,itemdeleted) plusmessages[], enabling user‑interfaces to refresh prices and display toast notifications with no additional queries.
Preconditions
- The cart is in an editable state (Draft/In‑Progress).
idbelongs to a discount that is already linked to the cart.- Caller has Delete permission on the discount object (enforced by CRUD/FLS checks within service layer).
Post-Conditions
- Target discount rows and dependent price adjustment records are deleted.
- Cart price totals are recalculated and persisted.
- Cardinality checks pass; otherwise the entire transaction rolls back.
- Client receives
actions+messagesfor immediate UI refresh.
Transactional Guarantees & Error Handling
- Entire flow executes in a single Apex transaction – any unhandled exception rolls back cart changes.
- Error payload follows the Standard Cart API schema (
code,severity,message).
| Parameter | Type | Description | Required | Default Value |
|---|---|---|---|---|
| id | String | Salesforce Id of the discount to be removed. | Yes | |
| cartId | String | Salesforce Id of the cart (Opportunity/Quote/Order) from which the discount has to be removed. | Yes | |
| price | Boolean | Indicates whether to run the pricing engine (true) or not (false). | TRUE |
Communication (vlocity_cmt)
Response Shape
- actions.itempricesupdated – To trigger a follow‑up call to
getCartLineItemPricesso the UI can redraw totals. - actions.itemdeleted – Contains a client‑side toast payload indicating that the discount has been deleted from the cart.
- messages[] – Top‑level array with readable outcome and HTTP‑style code (200 = success).
| Message | Description |
|---|---|
| Action is invalid | Line Item action is incorrect. |
| Changes are not allowed because they cause updates in product(s) {PRODUCT_NAME that is read-only. | If the IsChangesAllowed__c is set to False on the line item, then updating it is not allowed. |
| Compiled Data with key '{KEY}' not found | The CachedAPIResponse__c does not contain the '{KEY}' CacheKey for the latest and active ConfigurationSnapshotId. |
| CPQInvalidPriceList | No Pricelist associated with the cart. |
| CPQUnableToDeleteOrderActivated | Cannot delete discount since the Order is Activated. |
| Invalid account id 'CART_ID' . | Empty cartId input parameter or invalid cart type. |
| InvalidAccountId | Cart not associated with an Account. |
| Invalid attribute values found. | Issue with the AttributeSelectedValues__c. |
| No Header Object found. | Invalid Cart Id. |
| No product compiled data found. | No data related to the product in transaction has been found in the CachedAPIResponse__c. |
| Not able to query - {SOBJECT} | Error while performing a query on the SObject. |
| PricebookEntry not found for product : {PRODUCT_ID} with globalGroupKey {PRODUCT_GGK} | PricebookEntry information of the product in transaction is not found in the CartDocument. |
| This line item has been deleted already | When the delete discount is being performed on a disconnected line item. |
| Unable to Delete Discount | Discount was not deleted due to an issue. |
| Unable to populate selected attribute values | Error while populating the Selected Attribute Values in the CartDocument. |