Rule Engine Setup

Prerequisites

To setup and use the Rule Engine, you need to:

Have these user licenses Have these permissions Complete these tasks
and review these topics
before continuing
(First Time Setup)
  • FX CPQ minimum permissions

  • System permissions:

    • Customize Application

    • Manage Profiles and Permission Sets

    • View Setup and Configuration

Guidelines

Rules

For best performance, don’t select Requires Parent Item or specify a Parent Price Book Item for price book items included in rules.

Set up the Rule Processor.

Rule Criteria

You need to write a formula to define rule criteria.

You can use the following functions to define rule criteria for picklists and text fields:

Function Description Example

CONTAINS

Determines if a value in a field equals a specified value

CONTAINS(FX5__Job__r.Name,'Hydroblasting')

You can use the following functions to define rule criteria for multi-select picklists:

Function Description Example

INCLUDES

Determines if any value in a multi-select picklist equals a specified value in a positive search of what should be available

INCLUDES(FX5__Job__r.Job_Site__c, 'Dallas')

EXCLUDES

Determines if any value in a multi-select picklist does not equal a specified value in a negative search for what should not be available

EXCLUDES(FX5__Job__r.Job_Site__c, 'Houston')

You can use the following operators to define rule criteria:

Operator Description Example

== (Equal)

Evaluates if two values are equal

FX5__Job__r.FX5__Segment__c==Hydroblasting

!= (Not equal)

Evaluates if two values are not equal

FX5__Job__r.FX5__Segment__c!=Hydroblasting

< (Less Than)

Evaluates if a value is less than a specified value

Depth__c < 500

> (Greater Than)

Evaluates if a value is greater than a specified value

Depth__c < 500

⇐ (Less Than or Equal to)

Evaluates if a value is less than or equal to a specified value

Depth__c ⇐ 500

>= (Greater Than or Equal to)

Evaluates if a value is greater than or equal to a specified value

Depth__c >= 500

&& (And)

Use the && operator only. Do not use AND, and or And.

Evaluates if all values in an expression are TRUE

FX5__Job__r.Offshore__c==TRUE && BHT__c < 500

|| (Or)

Use the || operator only. Do not use OR, Or, or or.

Evaluates if at least one value in an expression is TRUE

FX5__Job__r.Offshore__c==TRUE || BHT__c < 500

Quote Rules

Quote rules have criteria that triggers rule actions if a quote or quote item meets the criteria.

Use information entered in quote or quote item fields for quote rule criteria.

Review CPQ Rules prior to working with quote rules for FieldFX CPQ.

Adding Quote Rules

Example: Adding a Rule with Quote-Based Criteria

In this example, we will add a quote rule using criteria based on the selection of Disposal Included for a quote.

Once we set up the rule, the following apply:

If you…​ then the Rule Engine…​

Select Disposal Included for a quote,

  • Adds the Disposal Charge item to every quote.

  • Prevents removal of the Disposal Charge item from any quote.

Deselect Disposal Included for a quote,

  • Removes the Disposal Charge item from every quote.

Setup Instructions
  1. Access FieldFX Back Office.

  2. Switch to Salesforce Classic.

  3. Add the Disposal Included checkbox:

    1. From Setup, enter object in the Quick Find box, then select Objects.

    2. Click Quote.

    3. Under Custom Fields & Relationships, click New.

    4. Select Checkbox and then click Next.

    5. In Field Label, enter Disposal Included and click Next.

    6. Click Visible twice and click Next.

    7. Select the page layouts on which to include the checkbox and click Save.

    8. Grant permissions for the checkbox.

  4. Add a rule:

    1. Open the price book for which to add the rule.

    2. Under Rules, click New Rule.

    3. In Rule Name, enter Disposal Included

    4. In Criteria, enter the following:

      Disposal_Included__c=true
    5. In Applies To, add "Quote__c" to Chosen.

    6. Select Is Active and click Save.

  5. Add a rule action:

    1. Under Rule Actions, click New Rule Action.

    2. In Price Book Item, select Disposal Included.

    3. In Type, select Required.

    4. Select Is Active and click Save.

  6. Run a script for the Disposal Included checkbox:

    1. Access Workbench.

    2. Select Utilities | Apex Execute.

    3. Enter the following script:

      System.debug(FX5.FXWorkerLauncher.DoWork('FX5.CustomFieldInfoHandler', null));
    4. Click Execute.

Example: Adding a Rule with Quote Item-Based Criteria

In this example, we will add a quote rule using criteria based on the Depth for a quote item.

Once we set up the rule, the following apply:

If you enter a Depth…​ Then the Rule Engine…​

Less than "1000" for the Run quote item,

  • Adds the Depth Charge 0-1000 ft item to the quote as a child item to the Run quote item.

  • Prevents removal of the Depth Charge 0-1000 ft item from the quote.

More than "1000" for the Run quote item,

  • Removes the Depth Charge 0-1000 ft item from the quote.

Setup Instructions
  1. Access FieldFX Back Office.

  2. Switch to Salesforce Classic.

  3. Add a Run catalog item:

    1. Open the Catalog Items tab and click New.

    2. In Item Code, enter Run

    3. In Description, enter Run for wireline jobs.

    4. In Sequence Number, enter a sequence number to use for the item.

    5. In Ticket Item Record Type, select a relevant option such as "Services" and click Save.

  4. Add a Run price book item:

    1. Under Price Book Items, click New Price Book Item:

    2. In Price Book, select the price book for which to add the rule.

    3. In Default Quantity, enter "1".

    4. In Included Quantity, enter "0" and click Save

  5. Add a Depth Charge 0-1000 ft catalog item:

    1. Open the Catalog Items tab and click New.

    2. In Item Code, enter DC<1000.

    3. In Description, enter "Depth Charge 0-1000 ft".

    4. In Sequence Number, enter a sequence number to use for the item.

    5. In Ticket Item Record Type, select a relevant option such as "Services" and click Save.

  6. Add a Depth Charge 0-1000 ft price book item:

    1. Under Price Book Items, click New Price Book Item.

    2. In Price Book, select the price book for which to add the rule.

    3. In Default Quantity, enter "1".

    4. In Included Quantity, enter "0".

    5. In Price, enter the price to charge for runs less than 1000 feet and click Save.

  7. Add the Depth field to the Quote Item object:

    1. From Setup, enter object in the Quick Find box, then select Objects.

    2. Click Quote Item.

    3. Under Custom Fields & Relationships, click New.

    4. Select Number.

    5. Click Next.

    6. In Field Label, enter Depth and click Next.

    7. Click Visible twice and click Next.

    8. Select the page layouts on which to include the field and click Save.

    9. Grant permissions for the field.

  8. Add a rule:

    1. Open the price book for which to add the rule.

    2. Under Rules, click New Rule.

    3. In Rule Name, enter "Depth Charge <1000".

    4. In Criteria, enter the following formula:

      Depth__c < 1000
    5. In Price Book Item, select the Run price book item.

      When you link a price book item to a rule, the Rule Engine triggers rule actions for that rule when you add the price book item to quotes.

    6. In Applies To, add "Quote__c" to Chosen.

    7. Select Is Active and click Save.

  9. Add a rule action:

    1. Under Rule Actions, click New Rule Action.

    2. In Price Book Item, select Depth Charge 0-1000 ft.

    3. In Type, select Required.

    4. Select Is Active and click Save

  10. Run a script for the Depth field:

    1. Access Workbench.

    2. Select Utilities | Apex Execute.

    3. Enter the following script:

      System.debug(FX5.FXWorkerLauncher.DoWork('FX5.CustomFieldInfoHandler', null));
    4. Click Execute.

Ticket Rules

Ticket rules have criteria that triggers rule actions if a job, ticket, or ticket item meets the criteria.

Use information entered in job, ticket, or ticket item fields for ticket rule criteria.

Review CPQ Rules prior to working with ticket rules for FieldFX CPQ.

Adding Ticket Rules

When adding rules, here are some examples showing how to add a rule with:

Example: Adding a Rule with Job-Based Criteria

In this example, we will add a ticket rule using criteria based on the selection of Offshore for a job.

Once we set up the rule, the following applies:

If you…​ Then the Rule Engine…​

Select Offshore for a job,

  • Adds the Deepwater Safety Pack item to every ticket.

  • Prevents removal of the Deepwater Safety Pack item from any ticket.

Deselect Offshore for a job,

  • Removes the Deepwater Safety Pack item from every ticket.

Setup Instructions
  1. Access FieldFX Back Office.

  2. Switch to Salesforce Classic.

  3. Add the Offshore checkbox:

    1. From Setup, enter object in the Quick Find box, then select Objects.

    2. Click Job.

    3. Under Custom Fields & Relationships, click New.

    4. Select Checkbox and click Next

    5. In Field Label, enter Offshore.

    6. Click Next.

    7. Click Visible twice and then click Next.

    8. Select the page layouts on which to include the checkbox and click Save

    9. Grant permissions for the checkbox.

  4. Add a rule:

    1. Open the price book for which to add the rule.

    2. Under Rules, click New Rule.

    3. In Rule Name, enter Offshore.

    4. In Criteria, enter the following:

      FX5__Job__r.Offshore__c=true
    5. In Applies To, add "Ticket__c" to Chosen.

    6. Select Is Active and click Save.

  5. Add a rule action:

    1. Under Rule Actions, click New Rule Action.

    2. In Price Book Item, select Deepwater Safety Pack.

    3. In Type, select Required.

    4. Select Is Active and click Save.

  6. Run a script for the Offshore checkbox:

    1. Access Workbench.

    2. Select Utilities | Apex Execute.

    3. Enter the following script:

      System.debug(FX5.FXWorkerLauncher.DoWork('FX5.CustomFieldInfoHandler', null));
    4. Click Execute.

Example: Adding a Rule with Ticket-Based Criteria

In this example, we will add a ticket rule using criteria based on the selection of Disposal Included for a ticket.

Once we set up the rule, the following applies:

If you…​ Then the Rule Engine…​

Select Disposal Included for a ticket,

  • Adds the Disposal Charge item to every ticket.

  • Prevents removal of the Disposal Charge item from any ticket.

Deselect Disposal Included for a ticket,

  • Removes the Disposal Charge item from every ticket.

Setup Instructions
  1. Access FieldFX Back Office.

  2. Switch to Salesforce Classic.

  3. Add the Disposal Included checkbox:

    1. From Setup, enter object in the Quick Find box, then select Objects.

    2. Click Ticket.

    3. Under Custom Fields & Relationships, click New.

    4. Select Checkbox and click Next.

    5. In Field Label, enter Disposal Included and click Next.

    6. Click Visible twice and click Next.

    7. Select the page layouts on which to include the checkbox and click Save.

    8. Grant permissions for the checkbox.

  4. Add a rule:

    1. Open the price book for which to add the rule.

    2. Under Rules, click New Rule.

    3. In Rule Name, enter Disposal Included.

    4. In Criteria, enter the following:

      Disposal_Included__c=true
    5. In Applies To, add "Ticket__c" to Chosen.

    6. Select Is Active and click Save.

  5. Add a rule action:

    1. Under Rule Actions, click New Rule Action.

    2. In Price Book Item, select Disposal Included.

    3. In Type, select Required.

    4. Select Is Active and click Save.

  6. Run a script for the Disposal Included checkbox:

    1. Access Workbench.

    2. Select Utilities | Apex Execute.

    3. Enter the following script:

      System.debug(FX5.FXWorkerLauncher.DoWork('FX5.CustomFieldInfoHandler', null));
    4. Click Execute.

Example: Adding a Rule with Job & Ticket-Based Criteria

In this example, we will add a ticket rule using criteria based on the selection of Offshore for a job and the value in BHT for a ticket.

Once we set up the rule, the following applies:

If you…​ Then the Rule Engine…​

Select Offshore for a job and enter a BHT less than "500" for a ticket,

  • Adds the SlimXtreme Slimhole HPHT Logging Platform item to every ticket.

  • Prevents removal of the SlimXtreme Slimhole HPHT Logging Platform item from any ticket.

Deselect Offshore for a job,

  • Removes the SlimXtreme Slimhole HPHT Logging Platform item from every ticket.

Enter a BHT more than "500" for a ticket,

  • Removes the SlimXtreme Slimhole HPHT Logging Platform item from the ticket.

Setup Instructions
  1. Access FieldFX Back Office.

  2. Switch to Salesforce Classic.

  3. Add the Offshore checkbox:

    1. From Setup, enter object in the Quick Find box, then select Objects.

    2. Click Job.

    3. Under Custom Fields & Relationships, click New.

    4. Select Checkbox and click Next.

    5. In Field Label, enter Offshore click Next.

    6. Click Visible twice and click Next.

    7. Select the page layouts on which to include the checkbox and click Save.

    8. Grant permissions for the checkbox.

  4. Add the BHT field:

    1. From Setup, enter object in the Quick Find box, then select Objects.

    2. Click Ticket.

    3. Under Custom Fields & Relationships, click New.

    4. Select Number and click Next

    5. In Field Label, enter BHT and click Next.

    6. Click Visible twice and click Next.

    7. Select the page layouts on which to include the field and click Save.

    8. Grant permissions for the field.

  5. Add a rule:

    1. Open the price book for which to add the rule.

    2. Under Rules, click New Rule.

    3. In Rule Name, enter BHT <500.

    4. In Criteria, enter the following:

      FX5__Job__r.Offshore__c=true && BHT__c<500
    5. In Applies To, add "Ticket__c" to Chosen.

    6. Select Is Active and click Save.

  6. Add a rule action:

    1. Under Rule Actions, click New Rule Action.

    2. In Price Book Item, select SlimXtreme Slimhole HPHT Logging Platform.

    3. In Type, select Required.

    4. Select Is Active and click Save.

  7. Run a script for the Offshore and BHT fields:

    1. Access Workbench.

    2. Select Utilities | Apex Execute.

    3. Enter the following script:

      System.debug(FX5.FXWorkerLauncher.DoWork('FX5.CustomFieldInfoHandler', null));
    4. Click Execute.

Example: Adding a Rule with Ticket Item-Based Criteria

In this example, we will add a ticket rule using criteria based on the Depth for a ticket item.

Once we set up the rule, the following applies:

If you…​ Then the Rule Engine…​

Enter a Depth less than "1000" for the Run ticket item

  • Adds the Depth Charge 0-1000 ft item to the ticket as a child item to the Run ticket item.

  • Prevents removal of the Depth Charge 0-1000 ft item from the ticket.

Enter a Depth more than "1000" for the Run ticket item,

  • Removes the Depth Charge 0-1000 ft item from the ticket.

Setup Instructions
  1. Access FieldFX Back Office.

  2. Switch to Salesforce Classic.

  3. Add a Run catalog item:

    1. Open the Catalog Items tab.

    2. Click New.

    3. In Item Code, enter "Run".

    4. In Description, enter Run for wireline jobs.

    5. In Sequence Number, enter a sequence number to use for the item.

    6. In Ticket Item Record Type, select a relevant option such as "Services".

    7. Click Save.

  4. Add a Run price book item:

    1. Under Price Book Items, click New Price Book Item.

    2. In Price Book, select the price book for which to add the rule.

    3. In Default Quantity, enter 1.

    4. In Included Quantity, enter 0.

    5. Click Save.

  5. Add a Depth Charge 0-1000 ft catalog item:

    1. Open the Catalog Items tab.

    2. Click New.

    3. In Item Code, enter DC<1000.

    4. In Description, enter Depth Charge 0-1000 ft.

    5. In Sequence Number, enter a sequence number to use for the item.

    6. In Ticket Item Record Type, select a relevant option such as "Services".

    7. Click Save.

  6. Add a Depth Charge 0-1000 ft price book item:

    1. Under Price Book Items, click New Price Book Item.

    2. In Price Book, select the price book for which to add the rule.

    3. In Default Quantity, enter 1.

    4. In Included Quantity, enter 0.

    5. In Price, enter the price to charge for runs less than 1000 feet.

    6. Click Save.

  7. Add the Depth field to the Ticket Item object:

    1. From Setup, enter object in the Quick Find box, then select Objects.

    2. Click Ticket Item.

    3. Under Custom Fields & Relationships, click New.

    4. Select Number.

    5. Click Next.

    6. In Field Label, enter Depth and click Next.

    7. Click Visible twice and click Next

    8. Select the page layouts on which to include the field and click Save

    9. Grant permissions for the field.

  8. Add a rule:

    1. Open the price book for which to add the rule.

    2. Under Rules, click New Rule.

    3. In Rule Name, enter Depth Charge <1000.

    4. In Criteria, enter the following formula:

      Depth__c <1000
    5. In Price Book Item, select the Run price book item.

      When you link a price book item to a rule, the Rule Engine triggers rule actions for that rule when you add the price book item to tickets.

    6. In Applies To, add "Ticket__c" to Chosen.

    7. Select Is Active and click Save

  9. Add a rule action:

    1. Under Rule Actions, click New Rule Action.

    2. In Price Book Item, select Depth Charge 0-1000 ft.

    3. In Type, select Required.

    4. Select Is Active and click Save

  10. Run a script for the Depth field:

    1. Access Workbench.

    2. Select Utilities | Apex Execute.

    3. Enter the following script:

      System.debug(FX5.FXWorkerLauncher.DoWork('FX5.CustomFieldInfoHandler', null));
    4. Click Execute.

CPQ Rules

You can add, edit, or clone CPQ Rules.

FieldFX CPQ rules work identically to other rules with these exceptions:

  • The CriteriaQueryFields and Criteria Stack fields do not generate when cloning or updating an existing rule.

  • CPQ handles these fields automatically in the background.

Do not add or change the CriteriaQueryFields and Criteria Stack fields when working with CPQ rules.
Screenshot highlighting the CriteriaStack and CriteriaQueryFields that should not be changed

Adding CPQ Rules

  1. Add a Quote Rule or Add a Ticket Rule.

    Do not complete the CriteriaQueryFields and Criteria Stack fields.

    FX CPQ handles these fields automatically in the background.

  2. Click Save.

Editing CPQ Rules

  1. Access FieldFX Back Office.

  2. Switch to Salesforce Classic.

  3. Select the Rules tab.

  4. Select the rule and select Edit.

  5. Update the Criteria field.

    Do not update the CriteriaQueryFields and CriteriaStack fields.

    CPQ handles these fields automatically in the background.

  6. Select Save.

Cloning CPQ Rules

  1. Access FieldFX Back Office.

  2. Switch to Salesforce Classic.

  3. Select the Rules tab.

  4. Select the rule and select Clone.

  5. Update the Rule Name and Price Book fields.

  6. Update the criteria.

    Do not complete the CriteriaQueryFields and Criteria Stack fields.

    FX CPQ handles these fields automatically in the background.

  7. Select Save.

Rule Processor

The Rule Processor gives you the ability to run large numbers of rules at once.

How It Works

The Rule Processor adds a criteria stack to every rule.

A criteria stack is a specially formatted string that contains rule criteria.

The advanced logic in the Rule Engine can then process large numbers of rules at once.

Setting Up the Rule Processor

  1. Access FieldFX Back Office.

  2. Switch to Salesforce Classic.

  3. Add a RESTEndPoint remote site setting:

    1. Open the Rule Processor tab:

      • If the Rule Processor displays, proceed to Step 4.

      • If an error message displays, proceed to Step b.

    2. Copy the domain listed in the error message.

      Example 1. Example domain name to copy

      Use your customized my domain URL that is specific to your org instead of your instance specific URL. You can find your my domain here.

      Don’t use instanced URLs when logging in to Salesforce with code or as a user. When your org is moved to another Salesforce instance, code using the instanced URL breaks. If you find instanced URLs in your code, replace them with your My Domain login URL or the default Salesforce login URL. See Log In to Salesforce with Code for more information.

    3. From Setup, enter remote in the Quick Find box, then select Remote Site Settings.

    4. Click New Remote Site.

    5. In Remote Site Name, enter RESTEndpoint.

    6. In Remote Site URL, enter the domain you copied in Step b.

      The Remote Site URL field is case-sensitive. Make sure the URL you enter uses the correct capitalization.

    7. Click Active and then click Save.

  1. Add an SFDCToolingAPI remote site setting:

    1. Click New Remote Site.

    2. In Remote Site Name, enter SFDCToolingAPI.

    3. In Remote Site URL, enter the domain in which your org runs.

      Example 2. Example URL to enter

      Copy the first part of the URL from the address bar in your browser when in FieldFX Back Office.

      Use your customized my domain URL that is specific to your org instead of your instance specific URL. You can find your my domain here.

      Don’t use instanced URLs when logging in to Salesforce with code or as a user. When your org is moved to another Salesforce instance, code using the instanced URL breaks. If you find instanced URLs in your code, replace them with your My Domain login URL or the default Salesforce login URL. See Log In to Salesforce with Code for more information.

      The Remote Site URL field is case-sensitive. Make sure the URL you enter uses the correct capitalization.
    4. Click Active.

    5. Click Save.

  2. Update Rule page layouts:

    1. From Setup, enter object in the Quick Find box, then select Objects.

    2. Click Rule.

    3. Under Page Layouts, click Edit next to a page layout for FieldFX Back Office.

    4. Drag CriteriaStack onto the layout and click Save.

    5. Repeat steps a to e for other page layouts as needed

  3. Grant permission for the Rule Processor fields:

    1. From Setup, enter permission in the Quick Find box, then select Permission Sets

    2. Open a permission set

    3. Under Apps, click Object Settings.

    4. Click Rules, then click Edit.

    5. Grant Read and Edit permission for the following fields:

      • Active Actions

      • CriteriaQueryFields

      • CriteriaStack

      • IsCriteriaDirty

    6. Click Save.

    7. Repeat the above steps for other permission sets as needed.

  4. Run scripts:

    1. Open a new tab in your browser.

    2. Access Workbench.

    3. Select Utilities | Apex Execute.

    4. Enter the following script:

      System.debug(FX5.FXWorkerLauncher.DoWork('FX5.CustomObjectInfoHandler', null));
    5. Click Execute.

    6. Delete the previously entered script, then enter the following script:

      System.debug(FX5.FXWorkerLauncher.DoWork('FX5.CustomFieldInfoHandler', null));
    7. Click Execute.

Running the Rule Processor

  1. Access FieldFX Back Office.

  2. Switch to Salesforce Classic.

  3. Open the Rule Processor tab.

  4. Click Flag Rules Dirty.

    A notification displays indicating how many rules are flagged for processing.

  5. Click Save.

    A notification displays indicating how many rules were processed.

  6. Repeat step 5 until you process every rule.

    Once you process every rule, the Rule Engine will have the capability of processing large numbers of rules at once.

Recommended Reading