{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":37865,"path":"order-management/rules_101.md","title":"Rules","bundle":null,"doc_type":null,"release":"australia","body":"\n# Rules\n\nLearn how to create and manage rules to deliver dynamic configuration experiences. Define conditions and actions to show or hide fields, display messages, calculate values, and generate bills of material \\(BOMs\\). Explore rule types, including visibility, message, inclusion, exclusion, determination, and product actions, to efficiently build intelligent, responsive configurations.\n\nAs the end user navigates through the configuration experience and populates information, rules provide its dynamic elements: hiding and showing content, calculating values, delivering recommendations and messages, and building the bill of materials \\(BOM\\).\n\nRules have two components: conditions and actions. CPQ supports six action types. The administration UI is a good place to add or edit a small number of rules. To update many rules at once, use the Matrix Loader. For more information, see [Matrix Loader: CSV rules upload](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/order-management/matrix_loader_csv_rules_upload.md).\n\nIn the administration UI, rules are accessible in two ways:\n\n-   Global rules: In the navigation pane, click **Rules**. The rule list administration page displays all rules defined in the environment. If your task is to add new rules, this is the only place in the Admin UI where you can initiate a new rule.\n-   Rules associated with a single blueprint: Click **Blueprints**, and then click a blueprint. Click the Rules tab to view the rules. Click a rule to open it.\n\n## Conditions\n\nCPQ rule conditions consist of a logical expression. At runtime, the rules engine executes the rule if the expression evaluates true.\n\nThe administrator can define several kinds of conditions:\n\n-   Any Condition Is Met: ORs the defined logical expressions.\n-   All Conditions Are Met: ANDs the defined logical expressions.\n-   Always \\(Action Input Change\\): Runs the rule whenever the end user alters a relevant input.\n-   Custom Logic is Met: Allows the administrator to define custom logic, including ANDs and ORs, among expressions.\n-   Advanced Function: Enables the administrator to write a script to define the rule condition.\n\n## Actions\n\nThe actions section of a rule defines the tasks the rule accomplishes when it runs \\(when its condition evaluates true\\). CPQ, unlike other engines, allows multiple actions and action types under one condition. This is a handy organizational feature that consolidates all tasks that need to be performed in the same scenario in one rule. The consolidation of multiple tasks with one condition also increases the efficiency with which the rules engine evaluates and accomplishes tasks. Increased efficiency translates to performance that the end user can see.\n\nOn the rule administration page, review the Actions section located below the summary and conditions area.\n\n-   List of actions: actions defined in this rule. Filter input allows you to find action\\(s\\) quickly, particularly when many actions are defined.\n-   Action editor pane: Allows Admin to review and edit the action selected in the list of actions.\n-   Add New Action button: define a new action for this rule. Six available action types are displayed in the action editor pane.\n\n## Hiding actions\n\nHiding actions hide an entire field from view to the end user. Use hiding actions to focus the end user’s attention, presenting only those fields that are relevant to the solution being configured. A hidden field retains its value.\n\n## Message actions\n\nMessage actions provide contextual information as the end user works through the configuration. The message is located relative to a designated field in the layout. Four message types are available.\n\n|Message type|Example|Notes|\n|------------|-------|-----|\n|Info|\\[Omitted image \"cpq-rules-message-type-example-info.png\"\\] Alt text: info message|No effect on configuration experience beyond message|\n|Warning|\\[Omitted image \"cpq-rules-message-type-example-warning.png\"\\] Alt text: warning message|No effect on configuration experience beyond message|\n|Error|\\[Omitted image \"cpq-rules-message-type-example-error.png\"\\] Alt text: error message|Disables the Quote button so the user cannot move forward until the error state is alleviated.|\n|Custom|Look is determined by user|The user can control whether this has no effect on configuration experience beyond message of if it disables the Quote button so the user cannot move forward until the error state is alleviated.|\n\nYou can customize the messages that are displayed. For more information, see [Change how messages are displayed to the end user](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/order-management/can_i_change_how_messages_are_displayed_to_the_end_user.md).\n\n## Inclusion/exclusion actions\n\nControl picklist field options using inclusion and exclusion actions. The two action types allow the administrator to define the set of field options in the most convenient manner possible. Both inclusion and exclusion rules may operate on the same picklist field. For a picklist, the displayed options are determined as follows:\n\n1.  Inclusion rules are applied to the set of options defined in the picklist field. If no inclusion rules are defined for the field, all of the picklist options continue past this step. The result of this step is the included set of picklist options.\n2.  The included set is then evaluated against any exclusion rules that apply. The result is the ‘displayed setʼ of options.\n\nPicklist options that are eliminated as a result of inclusion/exclusion actions can either be removed or disabled from the picklist menu of options visible to the end user.\n\nDuring runtime, if a picklist option is selected \\(either by an end user or via determination action\\), but inclusion/exclusion rules later determine that it is an invalid option, users can specify what happens if currently selected options become excluded. The user may choose to leave the selections unchanged, deselect the selections, or to deselect the selections and then select the first valid option instead. The Quote button is disabled until the end user corrects this error state.\n\n## Determination actions\n\nA determination action programmatically sets the value of a field. The administrator can choose whether the determined value is soft-set or read-only \\(forceset\\).\n\nIf an end user changes the value of a field that had been soft-set by a determination rule, CPQ displays a message to the user reminding them of the recommended value. The message does not limit the user from quoting the configuration; it is informational only. If the user reverts the value of the field to the determination-recommended value, the message goes away. The Admin can choose not to display this message.\n\n## Product actions\n\nProduct actions result in additions to the bill-of-material \\(BOM\\). When the BOM Type is set to Sales, a simple product action displays the product to the user as a line in the shopping cart. These sales BOM items are transferred to the Salesforce Quote Line Editor \\(SFDC QLE\\) when the configuration is quoted. If the BOM Type is set to Manufacturing, administrators usually do not show these lines to end users in the shopping cart. Manufacturing BOM items, however, are recorded and transferred to the SFDC Configuration Line Item object for communication with ERP and provisioning applications downstream.\n\n<table id=\"table_usc_hd4_khc\"><thead><tr><th>\n\nInput\n\n</th><th>\n\nNotes\n\n</th></tr></thead><tbody><tr><td>\n\nProduct\n\n</td><td>\n\nWhen BOM Type = Sales, the value in Product can be a 15-18 digit &lt;SFDC Product2 Id&gt; with format, 01t5f0000001tElAAI. CPQ pulls product code, description, and price from the SFDC Product2 record, or &lt;SFDC Product2 Product Code&gt;, or External ID depending on environment Product Id field settings.\n\n When BOM Type = Manufacturing, four options are available:\n\n-   &lt;SFDC Product2 Id&gt;\n-   &lt;SFDC Product2 Product Code&gt;\n-   External ID\n-   A valid string composed of letters, numbers, spaces, and the following special characters:`{}[]()|\\~`_^@?<=>;:/.-,+*ʼ&%$#”!`\n\n</td></tr><tr><td>\n\nQuantity\n\n</td><td>\n\n&lt;positive integer&gt;\n\n</td></tr><tr><td>\n\nBOM Type\n\n</td><td>\n\nSales: display in shopping cart. Quote pushes the item to the SFDC QLE and Configuration Line Items objects.\n\n Manufacturing: usually not shown to the end user. Quote pushes the item to the SFDC Configuration Line Items object.\n\n All: All BOM types display in shopping cart. Quote pushes the Sales and Manufacturing items to the Configuration Line Items object and Sales to the SFDC QLE object.\n\n</td></tr><tr><td>\n\nMandatory\n\n</td><td>\n\nTRUE: end user is unable to delete the item from the shopping cart.\n\n FALSE: end user is allowed to delete the item from the shopping cart.\n\n</td></tr></tbody>\n</table>## Advanced product actions\n\nIf your use case requires multilevel bills of material \\(BOMs\\), setting a dynamic quantity, or product attribution beyond that available in simple product actions, an advanced product action is necessary. The advanced product action allows you to write a script that outputs records to the ProductList object.\n\nThe following matrix describes available ProductList attributions.\n\n<table id=\"table_mgx_224_khc\"><thead><tr><th>\n\nProductList.&lt;param&gt;\n\n</th><th>\n\nReqOpt\n\n</th><th>\n\nValid Values\n\n</th><th>\n\nNotes\n\n</th></tr></thead><tbody><tr><td>\n\nbomType\n\n</td><td>\n\nR\n\n</td><td>\n\nSales, Manufacturing, All\n\n</td><td>\n\nIn Salesforce- integrated use cases, Manufacturing items are only written to LGK\\_\\_Configurat ionLineItem\\_\\_c; Sales items are written to the QLE and LGK\\_\\_Configurat ionLineItem\\_\\_c\n\n</td></tr><tr><td>\n\ndescription\n\n</td><td>\n\nO\n\n</td><td>\n\n&lt;text&gt;\n\n</td><td>\n\n \n\n</td></tr><tr><td>\n\nextended\n\n</td><td>\n\nO\n\n</td><td>\n\n&lt;JSON object&gt; consisting of key : value pairs \\(see note 1\\)\n\n</td><td>\n\nIf populated, this information transfers to LGK\\_Extended\\_I nformation\\_\\_c on the Configuration Line Item object in Salesforce, after the user clicks the Quote button\n\n</td></tr><tr><td rowspan=\"8\">\n\nid\n\n</td><td rowspan=\"8\">\n\nR\n\n</td><td colspan=\"2\">\n\nWhen SF-integrated use case AND bomType = Sales…\n\n</td></tr><tr><td>\n\nProduct2.Id, Product2.ProductCode, or External Id\n\n</td><td>\n\nSee note 2\n\n</td></tr><tr><td colspan=\"2\">\n\nWhen Headless/eCommerce AND bomType = Sales…\n\n</td></tr><tr><td>\n\nProductId or ProductCode\n\n</td><td>\n\nSee note 2\n\n</td></tr><tr><td colspan=\"2\">\n\nWhen SF-integrated AND bomType = Manufacturing…\n\n</td></tr><tr><td>\n\n&lt;text&gt;, Product2.Id, Product2.ProductCode, or External Id\n\n</td><td>\n\nAdministrators may add items not stored in Product2. If referencing records stored in Product2, note 2 applies\n\n</td></tr><tr><td colspan=\"2\">\n\nWhen Headless/eCommerce AND bomType = Manufacturing…\n\n</td></tr><tr><td>\n\n&lt;text&gt;, ProductId or ProductCode\n\n</td><td>\n\nAdmins may add items not stored in the Product object. If referencing records stored in Product, note 2 applies\n\n</td></tr><tr><td>\n\nlevel\n\n</td><td>\n\nO\n\n</td><td>\n\n&lt;integer&gt;\n\n</td><td>\n\nOptional; for Admin reference; does not drive app logic\n\n</td></tr><tr><td>\n\nnotes\n\n</td><td>\n\nO\n\n</td><td>\n\n&lt;text&gt;\n\n</td><td>\n\n \n\n</td></tr><tr><td>\n\norderNumber\n\n</td><td>\n\nO\n\n</td><td>\n\n&lt;integer&gt;\n\n</td><td>\n\nPopulate this parameter with numerical values that determine the sequence number of lines. Note: the ProductList object is filled by all product actions that trigger in the the blueprint. Limited to 28 digits.\n\n</td></tr><tr><td>\n\nparentProduct\n\n</td><td>\n\nO\n\n</td><td>\n\n&lt;text&gt;\n\n</td><td>\n\nIf populated, must match uniqueIdentifier of parent line. In SF- integrated use cases, the top-most parentProduct is the Configurable Product. Set this value to the Product2.Id or Product2.ProductCode of the Configurable Product.\n\n</td></tr><tr><td>\n\nprice\n\n</td><td>\n\nO\n\n</td><td>\n\n&lt;float&gt;\n\n</td><td>\n\nNegative and zero allowed. If unassigned, CPQ retrieves the base price from the product master.\n\n</td></tr><tr><td>\n\nqty\n\n</td><td>\n\nO\n\n</td><td>\n\n&lt;float&gt;\n\n</td><td>\n\nNegative and zero allowed. If unassigned, defaults to 1.\n\n</td></tr><tr><td>\n\nselectionType\n\n</td><td>\n\nO\n\n</td><td>\n\nRequired, Optional\n\n</td><td>\n\nIf left unpopulated, defaults to Required\n\n</td></tr><tr><td>\n\nuniqueIdentifier\n\n</td><td>\n\nR\n\n</td><td>\n\n&lt;unique text&gt;\n\n</td><td>\n\nString that uniquely identifies this line from others in this configuration session \\(see Unique Identifier attribute section below\\)\n\n</td></tr><tr><td>\n\nuom\n\n</td><td>\n\nO\n\n</td><td>\n\n&lt;text&gt;\n\n</td><td>\n\nUnit of measure\n\n</td></tr></tbody>\n</table>**Note:**\n\n1.  The ProductList.extended parameter can take a shallow JSON object. Example: `{ “key1”: “val1”, “key2”: “val2” }` Also, the Admin can define the extended key : value pairs for a ProductList record using JavaScript. Examples:`ProductList.extended[“key”] = “val”; ProductList.extended.key = “val”;`\n2.  To simplify the migration of product data between test and production environments, particularly in SF-integrated environments, administrators can request product actions to reference a ProductCode or External Id rather than ProductId. In the CPQ Admin, go to the Utilities menu in the navigation pane, and then click **Settings**. You can then set the Product Id field to Product Code, Partner Id, or External Id. If considering migrating from ProductId to ProductCode after go-live, you must coordinate the setting change with the values referenced in your Product actions and the implicit product actions in any picklist extension data you have defined.\n\n## Unique Identifier attribute\n\nCPQ passes the unique identifier of a product in CPQ to the Unique Line Id field on the quote line in Salesforce, allowing users to assign unique IDs to specific Salesforce quote lines.\n\nWhen using the parentProduct and uniqueIdentifier attributes for product hierarchy, if two child products have the same parent product and Product ID but need to be displayed separately in the BOM, each requires a unique “uniqueIdentifier”. This ensures that the UI treats them as unique products when listing them.\n\nSee the following sample script to observe how item hierarchy, differentiating parent items via uniqueIdentifier, bomTypes, and iterating through ProductList records can work: [Adv Product Action: Sample Hierarchical BOM](https://docs.google.com/document/d/1DmVwr1NTJyFLWM0RJB4wUWcA7fI-Jg4iikv9Cji3OVI/edit?usp=sharing).\n\n**Related topics**  \n\n\n[Quote line unique IDs](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/order-management/quote_line_unique_ids.md)\n\n"}}