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 id parameter from the cart identified by cartId.
  • 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 actions map (itempricesupdated, itemdeleted) plus messages[], 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).
  • id belongs 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 + messages for 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).
ParameterTypeDescriptionRequiredDefault Value
idStringSalesforce Id of the discount to be removed.Yes
cartIdStringSalesforce Id of the cart (Opportunity/Quote/Order) from which the discount has to be removed.Yes
priceBooleanIndicates 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 getCartLineItemPrices so 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).
MessageDescription
Action is invalidLine 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 foundThe CachedAPIResponse__c does not contain the '{KEY}' CacheKey for the latest and active ConfigurationSnapshotId.
CPQInvalidPriceListNo Pricelist associated with the cart.
CPQUnableToDeleteOrderActivatedCannot delete discount since the Order is Activated.
Invalid account id 'CART_ID' .Empty cartId input parameter or invalid cart type.
InvalidAccountIdCart 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 alreadyWhen the delete discount is being performed on a disconnected line item.
Unable to Delete DiscountDiscount was not deleted due to an issue.
Unable to populate selected attribute valuesError while populating the Selected Attribute Values in the CartDocument.