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)
  • FX CPQ minimum permissions

  • System permissions:

    • Customize Application

    • Manage Profiles and Permission Sets

    • View Setup and Configuration

Guidelines

Rule Structure

Rules have this structure:

Category Description Examples and
Other information

Trigger

Defining what causes the rule to run.

  • When a record is created

  • When a field value changes

  • When a record is saved

Condition

The "If" part of the rule.

Logical statements like

  • Job Type = "Hot Shot"

  • Ticket Status = "Complete"

  • Product Category = "Rental"

Action

The system executes something automatically

  • Show a message to the user

  • Prevent saving until fields are filled

  • Automatically set a field value

  • Require approval before proceeding

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

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

  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, continue to the next step.

    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.

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

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