---
schema_version: "1"
id: 7e6024a7116790f41330556665e353bf4ebe86adfca20ac4c5a02404a08a5f05
title: Defining Advanced Rules Using Configuration Type
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/industries/cme/guides/comms-t-defining-advanced-rules-using-configuration-type.md
canonical_url: https://developer.salesforce.com/docs/industries/cme/guide/comms-t-defining-advanced-rules-using-configuration-type.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: f0309b87929e2081b3ed7a01b743b8c139ab31a547ba0c3626a366e3afe75e95
products:
  - Communications, Media, Energy and Utilities APIs (Managed Package)
  - Industries Developer Documentation
---
# Defining Advanced Rules Using Configuration Type

Use configuration type advanced rules to create product compatibility rules based on a condition. Compatibility rules determine if a product combination is valid.

Using Compatibility Rules, you can define that, when a product is added to the cart, related products are added with it. You can also automatically add, automatically remove, or recommend products based on other products in the cart.

For example, if you add more than one Samsung Galaxy S10e to the cart, then a Samsung Galaxy S20e is automatically added to the cart at no additional cost. You can also add another condition where if you purchase a modem or a mobile phone, such as a Samsung Galaxy S20e, then you get a six-month Internet plan.

To define advanced rules using Configuration type:

1.  Set up an interface implementation named ProductValidationInterface. For more information, see [Interfaces, Implementations, and Services](https://help.salesforce.com/s/articleView?id=ind.v_dev_t_interfacesimplementationsand_services_651813.htm) and [Adding a New Interface Implementation](https://help.salesforce.com/s/articleView?id=ind.v_dev_t_adding_a_new_interface_implementation_658122.htm).

    Set the default interface/Active Implementation Class to **ValidationRulesImplementation**. The interface implementation should point to Product Relationships.

    ![Product Validation Interface](https://developer.salesforce.com/docs/media/dc_interfaceimplement.png)

2.  Create a product relationship. For more information, see [Product Relationships Overview](https://help.salesforce.com/s/articleView?id=ind.comms_product_relationships_overview.htm).

    ![Product relationship](https://developer.salesforce.com/docs/media/dc_productrelation.png)

    - Set the **Relation Type** to Auto-Add.

    - Set the **AddMode** to `asRoot`. The Samsung Galaxy S10e is the root.

3.  Set up an Entity Filter. For more information, see [Create a Compatibility Rule](https://help.salesforce.com/s/articleView?id=ind.comms_create_a_compatibility_rule.htm).

    ![Set up an Entity Filter](https://developer.salesforce.com/docs/media/dc_entityfilter.png)

    - Make sure the quantity is greater than 1 so the **Auto-Add** works.

    - For **Entity Filter Conditions**, the Field/Attribute/Related Object list is populated according to your selection in the **Filter On Object Name** field.

4.  From the App Launcher, click Vlocity Rules. For more information, see [Accessing the Vlocity Rule Builder](https://help.salesforce.com/s/articleView?id=ind.comms_accessing_the_vlocity_rule_builder.htm).

5.  Click New.

6.  Click Edit Mode.

7.  Enter a rule name and a description.

8.  In the first field, select Configuration.

9.  In the second field, use Order Product\<OrderItem>. Opportunity and Quote are not applicable.

10. Set the rule to Active.

    ![Customer SLA Rule Set](https://developer.salesforce.com/docs/media/dc_vlocityrulebuilder.png)

11. Expand the FILTERS AND ACTIONS list and click the Filters button.

12. Click Add to Rule Filter and specify the conditions to satisfy.

13. Click the Actions button and specify the action to execute to satisfy that condition. For example, if you have an order line item with Samsung Galaxy S10e, then the Samsung Galaxy S20e will be automatically added as the action to satisfy the condition.

14. Repeat the above steps to add more conditions and actions.

15. Click Save.

16. In your API platform, set the HTTP method to POST.

17. Add the Samsung Galaxy S10e product to an empty basket:

    `/services/apexrest/vlocity_digital/v3/catalogs/catalogCode/basket`

    ![Add product to an empty basket](https://developer.salesforce.com/docs/media/dc_addproduct.png)

    The default quantity of the Samsung Galaxy S10e is 1. The Samsung Galaxy S20e has not yet been auto-added because the condition states that the Samsung Galaxy S10e product equals 1. Once the quantity of Samsung Galaxy S10e is greater than 1, then the Samsung Galaxy S20e is automatically added.

18. Add the bundle context to the request body, which upgrades the line item quantity to 2.

    ![Add the bundle context to the request body](https://developer.salesforce.com/docs/media/dc_addbundlecontext.png)

The Samsung Galaxy S20e is automatically added.

You can update fields that are related to the cart line items/order items. Based on those fields, you can write the entity filter. You can not use any fields on the order unless they are related to the order contract.

Logged-in users can pass all the entity filters that are related to Account ID and Contract ID as part of the orders. Anonymous users do not get those additional entity filters.
