Rule Engine Setup
It is important to correctly set up the rule engine for FieldFX so data and processes follow the right business topic without relying on users to remember every detail. Rules can be created for tickets, quotes, and CPQ.
These are the advantages to a correct rule engine setup:
Advantage | Description | Example |
---|---|---|
Automates Business Logic |
Conditions are applied automatically. |
If a certain product is selected, the system can auto-populate default pricing, required resources, or enforce compliance rules. |
Ensures Data Accuracy |
The rules helps prevent users from enter incorrect or incomplete data. |
The rule can block the saving of a ticket unless a safety form is completed. |
Streamlines Processes |
Manual checks can be reduced by guiding users with prompts, defaults, and validations speeding up quoting, scheduling, job completions, and billing |
n/a |
Support CPQ (Configure-Price-Quote) |
For CPQ, rules ensure only valid product combinations, discounts, and pricing structures are applied preventing errors in proposals and invoices. |
n/a |
Back Office and Mobile Consistency |
Back Office rules that are set up carry over to FieldFX Mobile so users follow the same standards without needing to know all the policies. |
n/a |
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
Rule Structure
Rules have this structure:
Category | Description | Examples and Other information |
---|---|---|
Trigger |
Defining what causes the rule to run. |
|
Condition |
The "If" part of the rule. |
Logical statements like
|
Action |
The system executes something automatically |
|
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 |
|
Rule Processor
The Rule Processor gives you the ability to run large numbers of rules at once.
How the Rule Processor 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.
Set 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, continue to the next step.
-
-
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.
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 these steps 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.
-
Run 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 the above steps 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.