Relies On Product Relationships in Industries CPQ

This section provides information about Relies On relationship capability within Industries Configure, Price, Quote (CPQ).

Linear Relationship (“Relies On”) is an alternative product modeling approach to avoid the complexity of hierarchical product modeling. In hierarchical product design, related products are grouped using a parent-child relationship, where child products are implicitly dependent on other products within the hierarchy. In contrast, the Linear Design approach doesn't tightly couple products within a hierarchy. Instead, products are defined simply, with linear relationships indicating dependencies (also known as "Relies On") on other products.

  • Use Relies On Relationship APIs from the CPQ Cart for establishing the relationship between two related products defined using the Relies On type advanced rule.

  • Relationships are then stored in the Order Product Relationship or Quote Product Relationship depending upon the type of Cart.

  • To achieve this, perform the following.

    1. From the Developer Console, click File > New > Apex Class.
    2. Create a new class with the name CPQAppHandlerHookImplementation.
    3. Copy the following code and add it to newly created CPQAppHandlerHookImplementation class.
  1. Create a new interface with the name CpqAppHandlerHookInterface and with the following configuration.

CPQ Handler

The CPQAppHandlerHookImplementation class invokes the following methods.

  • postCartsItems.PostInvoke This method is invoked whenever a new offer is added to the cart. Based on the newly added product and already existing products in the cart, following variables are important.

    • orderProdRelsMap: Contains existing OrderProductRelationship that are already linked and ProductRelationship list that can be linked.
    • xliToRelProdListMap: Contains against each lineitem, which all "Related Product(s)" exist in the Cart.
    • lineItemListOfLinkagesMap: Contains the relationships that are eligible to be added if not already added.
  • deleteCartsItems.PreInvoke This method is invoked whenever the LineItem is deleted, and if that LineItem contains any added Relies On Relationship in the cart already, then respective relationship is deleted.

    • lineItemToDel: Contains the LineItem on which delete operation is invoked and for which existing relationship(s) needs to be deleted.

Following remote methods are used.

This method fetches relationships based on XLIs present in the Order/Quote. This response contains the following.

  • OrderProductRelationship: Linked Order Product Relationships
  • QuoteProductRelationship: Linked Quote Item Relationships
  • ProductRelationship: List of eligible Relies On Relationships that can be linked

This method inks relationships between XLIs and related XLIs present in the Order/Quote. This response contains the linked relationship, based on the type of Cart (Order/Quote).

  • Method Name for Order type Cart: linkProductsForOrder
  • Method Name for Quote type Cart: linkProducts

Sample Request

Sample Response

This method fetches already linked rules quantity for a given XLI present in the Order/Quote. This response contains the following.

  • Method Name for Order type Cart: getAddedRelatedLineItemQuantityForOrder
  • Method Name for Quote type Cart: getAddedRelatedLineItemQuantity

Response contains the information same as what is inserted in sObjects OrderProductRelationship / QuoteProductRelationship.

This method deletes the already linked relationships when XLI is deleted from the Order/Quote. This response contains the following.

  • Method Name for Order type Cart: deleteOrderItemRelationships
  • Method Name for Quote type Cart: deleteQuoteLineItemRelationships