Rule Engine Setup

Prerequisites

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) [1]

Evaluates if all values in an expression are TRUE

FX5__Job__r.Offshore__c==TRUE && BHT__c < 500

|| (Or) [2]

Evaluates if at least one value in an expression is TRUE

FX5__Job__r.Offshore__c==TRUE || BHT__c < 500

Quote Rules

Basics

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 select Disposal Included for a quote, the Rule Engine:

    • Adds the Disposal Charge item to every quote.

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

  • If you deselect Disposal Included for a quote, the Rule Engine:

    • 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

    5. Click Next

    6. In Field Label, enter "Disposal Included"

    7. Click Next

    8. Click Visible twice

    9. Click Next

    10. Select the page layouts on which to include the checkbox

    11. Click Save

    12. 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

    7. 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

    5. 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 less than "1000" for the Run quote item, the Rule Engine:

    • 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.

  • If you enter a Depth more than "1000" for the Run quote item, the Rule Engine:

    • 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

    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 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"

    7. Click Next

    8. Click Visible twice

    9. Click Next

    10. Select the page layouts on which to include the field

    11. Click Save

    12. 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

    8. 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

    5. 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

Basics

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

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 select Offshore for a job, the Rule Engine:

    • Adds the Deepwater Safety Pack item to every ticket.

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

  • If you deselect Offshore for a job, the Rule Engine:

    • 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

    5. Click Next

    6. In Field Label, enter "Offshore"

    7. Click Next

    8. Click Visible twice

    9. Click Next

    10. Select the page layouts on which to include the checkbox

    11. Click Save

    12. 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

    7. 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

    5. 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 select Disposal Included for a ticket, the Rule Engine:

    • Adds the Disposal Charge item to every ticket.

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

  • If you deselect Disposal Included for a ticket, the Rule Engine:

    • 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

    5. Click Next

    6. In Field Label, enter "Disposal Included"

    7. Click Next

    8. Click Visible twice

    9. Click Next

    10. Select the page layouts on which to include the checkbox

    11. Click Save

    12. 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

    7. 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

    5. 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 select Offshore for a job and enter a BHT less than "500" for a ticket, the Rule Engine:

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

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

  • If you deselect Offshore for a job, the Rule Engine:

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

  • If you enter a BHT more than "500" for a ticket, the Rule Engine:

    • 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

    5. Click Next

    6. In Field Label, enter "Offshore"

    7. Click Next

    8. Click Visible twice

    9. Click Next

    10. Select the page layouts on which to include the checkbox

    11. Click Save

    12. 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

    5. Click Next

    6. In Field Label, enter "BHT"

    7. Click Next

    8. Click Visible twice

    9. Click Next

    10. Select the page layouts on which to include the field

    11. Click Save

    12. 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

    7. 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

    5. 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 enter a Depth less than "1000" for the Run ticket item, the Rule Engine:

    • 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.

  • If you enter a Depth more than "1000" for the Run ticket item, the Rule Engine:

    • 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"

    7. Click Next

    8. Click Visible twice

    9. Click Next

    10. Select the page layouts on which to include the field

    11. Click Save

    12. 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

    8. 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

    5. 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

Basics

FieldFX CPQ rules work identically to other rules with one exception:

  • 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

  5. Select Edit

  6. Update the Criteria field

    Do not update the CriteriaQueryFields and CriteriaStack fields.

    CPQ handles these fields automatically in the background.

  7. Select Save

Cloning CPQ Rules

  1. Access FieldFX Back Office

  2. Switch to Salesforce Classic

  3. Select the Rules tab

  4. Select the rule

  5. Select Clone

  6. Update the Rule Name and Price Book fields

  7. Update the criteria

    Do not complete the CriteriaQueryFields and Criteria Stack fields.

    FX CPQ handles these fields automatically in the background.

  8. Select Save

Rule Processor

Basics

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
    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

    8. Click Save

  4. 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.

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

    5. Click Save

  5. 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

    5. Click Save

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

  6. 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

    5. Click Edit

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

      • Active Actions

      • CriteriaQueryFields

      • CriteriaStack

      • IsCriteriaDirty

    7. Click Save

    8. Repeat steps a to g for other permission sets as needed

  7. 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


1. Use the && operator only. Do not use AND, and or And
2. Use the || operator only. Do not use OR, Or, or or