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) |
---|---|---|
|
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 |
|
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 |
|
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 |
|
You can use the following operators to define rule criteria:
Operator | Description | Example |
---|---|---|
== (Equal) |
Evaluates if two values are equal |
|
!= (Not equal) |
Evaluates if two values are not equal |
|
< (Less Than) |
Evaluates if a value is less than a specified value |
|
> (Greater Than) |
Evaluates if a value is greater than a specified value |
|
⇐ (Less Than or Equal to) |
Evaluates if a value is less than or equal to a specified value |
|
>= (Greater Than or Equal to) |
Evaluates if a value is greater than or equal to a specified value |
|
&& (And) Use the |
Evaluates if all values in an expression are |
|
|| (Or) Use the |
Evaluates if at least one value in an expression is |
|
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, |
|
Deselect Disposal Included for a quote, |
|
Setup Instructions
-
Add the Disposal Included checkbox:
-
From Setup, enter
object
in the Quick Find box, then select Objects. -
Click Quote.
-
Under Custom Fields & Relationships, click New.
-
Select Checkbox and then click Next.
-
In Field Label, enter
Disposal Included
and click Next. -
Click Visible twice and click Next.
-
Select the page layouts on which to include the checkbox and click Save.
-
Grant permissions for the checkbox.
-
-
Add a rule:
-
Open the price book for which to add the rule.
-
Under Rules, click New Rule.
-
In Rule Name, enter
Disposal Included
-
In Criteria, enter the following:
Disposal_Included__c=true
-
In Applies To, add "Quote__c" to Chosen.
-
Select Is Active and click Save.
-
-
Add a rule action:
-
Under Rule Actions, click New Rule Action.
-
In Price Book Item, select Disposal Included.
-
In Type, select Required.
-
Select Is Active and click Save.
-
-
Run a script for the Disposal Included checkbox:
-
Select Utilities | Apex Execute.
-
Enter the following script:
System.debug(FX5.FXWorkerLauncher.DoWork('FX5.CustomFieldInfoHandler', null));
-
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, |
|
More than "1000" for the Run quote item, |
|
Setup Instructions
-
Add a Run catalog item:
-
Open the Catalog Items tab and click New.
-
In Item Code, enter
Run
-
In Description, enter
Run for wireline jobs
. -
In Sequence Number, enter a sequence number to use for the item.
-
In Ticket Item Record Type, select a relevant option such as "Services" and click Save.
-
-
Add a Run price book item:
-
Under Price Book Items, click New Price Book Item:
-
In Price Book, select the price book for which to add the rule.
-
In Default Quantity, enter "1".
-
In Included Quantity, enter "0" and click Save
-
-
Add a Depth Charge 0-1000 ft catalog item:
-
Open the Catalog Items tab and click New.
-
In Item Code, enter
DC<1000
. -
In Description, enter "Depth Charge 0-1000 ft".
-
In Sequence Number, enter a sequence number to use for the item.
-
In Ticket Item Record Type, select a relevant option such as "Services" and click Save.
-
-
Add a Depth Charge 0-1000 ft price book item:
-
Under Price Book Items, click New Price Book Item.
-
In Price Book, select the price book for which to add the rule.
-
In Default Quantity, enter "1".
-
In Included Quantity, enter "0".
-
In Price, enter the price to charge for runs less than 1000 feet and click Save.
-
-
Add the Depth field to the Quote Item object:
-
From Setup, enter
object
in the Quick Find box, then select Objects. -
Click Quote Item.
-
Under Custom Fields & Relationships, click New.
-
Select Number.
-
Click Next.
-
In Field Label, enter
Depth
and click Next. -
Click Visible twice and click Next.
-
Select the page layouts on which to include the field and click Save.
-
Grant permissions for the field.
-
-
Add a rule:
-
Open the price book for which to add the rule.
-
Under Rules, click New Rule.
-
In Rule Name, enter "Depth Charge <1000".
-
In Criteria, enter the following formula:
Depth__c < 1000
-
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.
-
In Applies To, add "Quote__c" to Chosen.
-
Select Is Active and click Save.
-
-
Add a rule action:
-
Under Rule Actions, click New Rule Action.
-
In Price Book Item, select Depth Charge 0-1000 ft.
-
In Type, select Required.
-
Select Is Active and click Save
-
-
Run a script for the Depth field:
-
Select Utilities | Apex Execute.
-
Enter the following script:
System.debug(FX5.FXWorkerLauncher.DoWork('FX5.CustomFieldInfoHandler', null));
-
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, |
|
Deselect Offshore for a job, |
|
Setup Instructions
-
Add the Offshore checkbox:
-
From Setup, enter
object
in the Quick Find box, then select Objects. -
Click Job.
-
Under Custom Fields & Relationships, click New.
-
Select Checkbox and click Next
-
In Field Label, enter
Offshore
. -
Click Next.
-
Click Visible twice and then click Next.
-
Select the page layouts on which to include the checkbox and click Save
-
Grant permissions for the checkbox.
-
-
Add a rule:
-
Open the price book for which to add the rule.
-
Under Rules, click New Rule.
-
In Rule Name, enter
Offshore
. -
In Criteria, enter the following:
FX5__Job__r.Offshore__c=true
-
In Applies To, add "Ticket__c" to Chosen.
-
Select Is Active and click Save.
-
-
Add a rule action:
-
Under Rule Actions, click New Rule Action.
-
In Price Book Item, select Deepwater Safety Pack.
-
In Type, select Required.
-
Select Is Active and click Save.
-
-
Run a script for the Offshore checkbox:
-
Select Utilities | Apex Execute.
-
Enter the following script:
System.debug(FX5.FXWorkerLauncher.DoWork('FX5.CustomFieldInfoHandler', null));
-
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, |
|
Deselect Disposal Included for a ticket, |
|
Setup Instructions
-
Add the Disposal Included checkbox:
-
From Setup, enter
object
in the Quick Find box, then select Objects. -
Click Ticket.
-
Under Custom Fields & Relationships, click New.
-
Select Checkbox and click Next.
-
In Field Label, enter
Disposal Included
and click Next. -
Click Visible twice and click Next.
-
Select the page layouts on which to include the checkbox and click Save.
-
Grant permissions for the checkbox.
-
-
Add a rule:
-
Open the price book for which to add the rule.
-
Under Rules, click New Rule.
-
In Rule Name, enter
Disposal Included
. -
In Criteria, enter the following:
Disposal_Included__c=true
-
In Applies To, add "Ticket__c" to Chosen.
-
Select Is Active and click Save.
-
-
Add a rule action:
-
Under Rule Actions, click New Rule Action.
-
In Price Book Item, select Disposal Included.
-
In Type, select Required.
-
Select Is Active and click Save.
-
-
Run a script for the Disposal Included checkbox:
-
Select Utilities | Apex Execute.
-
Enter the following script:
System.debug(FX5.FXWorkerLauncher.DoWork('FX5.CustomFieldInfoHandler', null));
-
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… |
---|---|
Deselect Offshore for a job, |
|
Enter a BHT more than "500" for a ticket, |
|
Setup Instructions
-
Add the Offshore checkbox:
-
From Setup, enter
object
in the Quick Find box, then select Objects. -
Click Job.
-
Under Custom Fields & Relationships, click New.
-
Select Checkbox and click Next.
-
In Field Label, enter
Offshore
click Next. -
Click Visible twice and click Next.
-
Select the page layouts on which to include the checkbox and click Save.
-
Grant permissions for the checkbox.
-
-
Add the BHT field:
-
From Setup, enter
object
in the Quick Find box, then select Objects. -
Click Ticket.
-
Under Custom Fields & Relationships, click New.
-
Select Number and click Next
-
In Field Label, enter
BHT
and click Next. -
Click Visible twice and click Next.
-
Select the page layouts on which to include the field and click Save.
-
Grant permissions for the field.
-
-
Add a rule:
-
Open the price book for which to add the rule.
-
Under Rules, click New Rule.
-
In Rule Name, enter
BHT <500
. -
In Criteria, enter the following:
FX5__Job__r.Offshore__c=true && BHT__c<500
-
In Applies To, add "Ticket__c" to Chosen.
-
Select Is Active and click Save.
-
-
Add a rule action:
-
Under Rule Actions, click New Rule Action.
-
In Price Book Item, select SlimXtreme Slimhole HPHT Logging Platform.
-
In Type, select Required.
-
Select Is Active and click Save.
-
-
Run a script for the Offshore and BHT fields:
-
Select Utilities | Apex Execute.
-
Enter the following script:
System.debug(FX5.FXWorkerLauncher.DoWork('FX5.CustomFieldInfoHandler', null));
-
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 |
|
Enter a Depth more than "1000" for the Run ticket item, |
|
Setup Instructions
-
Add a Run catalog item:
-
Open the Catalog Items tab.
-
Click New.
-
In Item Code, enter "Run".
-
In Description, enter
Run for wireline jobs
. -
In Sequence Number, enter a sequence number to use for the item.
-
In Ticket Item Record Type, select a relevant option such as "Services".
-
Click Save.
-
-
Add a Run price book item:
-
Under Price Book Items, click New Price Book Item.
-
In Price Book, select the price book for which to add the rule.
-
In Default Quantity, enter
1
. -
In Included Quantity, enter
0
. -
Click Save.
-
-
Add a Depth Charge 0-1000 ft catalog item:
-
Open the Catalog Items tab.
-
Click New.
-
In Item Code, enter
DC<1000
. -
In Description, enter
Depth Charge 0-1000 ft
. -
In Sequence Number, enter a sequence number to use for the item.
-
In Ticket Item Record Type, select a relevant option such as "Services".
-
Click Save.
-
-
Add a Depth Charge 0-1000 ft price book item:
-
Under Price Book Items, click New Price Book Item.
-
In Price Book, select the price book for which to add the rule.
-
In Default Quantity, enter
1
. -
In Included Quantity, enter
0
. -
In Price, enter the price to charge for runs less than 1000 feet.
-
Click Save.
-
-
Add the Depth field to the Ticket Item object:
-
From Setup, enter
object
in the Quick Find box, then select Objects. -
Click Ticket Item.
-
Under Custom Fields & Relationships, click New.
-
Select Number.
-
Click Next.
-
In Field Label, enter
Depth
and click Next. -
Click Visible twice and click Next
-
Select the page layouts on which to include the field and click Save
-
Grant permissions for the field.
-
-
Add a rule:
-
Open the price book for which to add the rule.
-
Under Rules, click New Rule.
-
In Rule Name, enter
Depth Charge <1000
. -
In Criteria, enter the following formula:
Depth__c <1000
-
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.
-
In Applies To, add "Ticket__c" to Chosen.
-
Select Is Active and click Save
-
-
Add a rule action:
-
Under Rule Actions, click New Rule Action.
-
In Price Book Item, select Depth Charge 0-1000 ft.
-
In Type, select Required.
-
Select Is Active and click Save
-
-
Run a script for the Depth field:
-
Select Utilities | Apex Execute.
-
Enter the following script:
System.debug(FX5.FXWorkerLauncher.DoWork('FX5.CustomFieldInfoHandler', null));
-
Click Execute.
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. |
Adding CPQ Rules
-
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.
-
Click Save.
Editing CPQ Rules
-
Select the Rules tab.
-
Select the rule and select Edit.
-
Update the Criteria field.
Do not update the CriteriaQueryFields and CriteriaStack fields.
CPQ handles these fields automatically in the background.
-
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
-
Add a RESTEndPoint remote site setting:
-
Open the Rule Processor tab:
-
If the Rule Processor displays, proceed to Step 4.
-
If an error message displays, proceed to Step b.
-
-
Copy the domain listed in the error message.
Example 1. Example domain name to copyUse 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.
-
From Setup, enter
remote
in the Quick Find box, then select Remote Site Settings. -
Click New Remote Site.
-
In Remote Site Name, enter
RESTEndpoint
. -
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.
-
Click Active and then click Save.
-
-
Add an SFDCToolingAPI remote site setting:
-
Click New Remote Site.
-
In Remote Site Name, enter
SFDCToolingAPI
. -
In Remote Site URL, enter the domain in which your org runs.
Example 2. Example URL to enterCopy 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. -
Click Active.
-
Click Save.
-
-
Update Rule page layouts:
-
From Setup, enter
object
in the Quick Find box, then select Objects. -
Click Rule.
-
Under Page Layouts, click Edit next to a page layout for FieldFX Back Office.
-
Drag CriteriaStack onto the layout and click Save.
-
Repeat steps a to e for other page layouts as needed
-
-
Grant permission for the Rule Processor fields:
-
From Setup, enter
permission
in the Quick Find box, then select Permission Sets -
Open a permission set
-
Under Apps, click Object Settings.
-
Click Rules, then click Edit.
-
Grant Read and Edit permission for the following fields:
-
Active Actions
-
CriteriaQueryFields
-
CriteriaStack
-
IsCriteriaDirty
-
-
Click Save.
-
Repeat the above steps for other permission sets as needed.
-
-
Run scripts:
-
Open a new tab in your browser.
-
Select Utilities | Apex Execute.
-
Enter the following script:
System.debug(FX5.FXWorkerLauncher.DoWork('FX5.CustomObjectInfoHandler', null));
-
Click Execute.
-
Delete the previously entered script, then enter the following script:
System.debug(FX5.FXWorkerLauncher.DoWork('FX5.CustomFieldInfoHandler', null));
-
Click Execute.
-
Running the Rule Processor
-
Open the Rule Processor tab.
-
Click Flag Rules Dirty.
A notification displays indicating how many rules are flagged for processing.
-
Click Save.
A notification displays indicating how many rules were processed.
-
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.