---
schema_version: "1"
id: a9048e381ff9e2419f1268377366928f64beb044e73cd29376eb0923d09527ce
title: Write a Strategy Builder Expression
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/nba_strategy_expressions.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.nba_strategy_expressions.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: d22c10944a3f2c3a5012353b429a77c552e292d1b8a17b3f41b60c5a138e165f
description: Create unique expressions using logic from the Salesforce expression builder to filter recommendations, select or deselect branches, and determine which recommendations are available for consideration in a strategy.
products:
  - Flow Builder
  - Salesforce Platform
release: "264"
---
# Write a Strategy Builder Expression

Create unique expressions using logic from the Salesforce expression builder to filter recommendations, select or deselect branches, and determine which recommendations are available for consideration in a strategy.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;"><a href="https://help.salesforce.com/s/articleView?id=platform.nba_ref_editions.htm&amp;release=264.0.0&amp;type=5" title="Learn about the editions and user interfaces that support Next Best Action.">View supported editions for Next Best Action</a>.</td></tr></tbody></table>

Strategy Builder expressions, found on the Filter and Branch Selector elements, use standard Salesforce formula functions. To learn more about creating formulas in Salesforce, see [Formula Operators and Functions by Context](https://help.salesforce.com/s/articleView?id=platform.customize_functions.htm&language=en_US).

Strategies are designed to work with a particular object like Case or Contact. Strategy Builder elements use $Record as a placeholder for the actual record that gets passed in when a strategy runs.

- Select the element you need for your strategy: **Filter** or **Branch Selector**.
- Enter your expression. You can build expressions in two different modes: standard and advanced. Standard is declarative: search and select to build your formula. Use advanced mode for more complex expressions, when a given operator is unavailable in standard mode, or when you use concatenation.
- In standard mode, set up conditions. At run time, the conditions are evaluated in the order you specify.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:24%">
          <col style="width:76%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d160393e91">Column Header</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d160393e94">Description</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Column Header" class="slds-cell-wrap" style="vertical-align:top;" headers="d160393e91 ">
              <samp class="parmname">Resource</samp>
            </td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d160393e94 ">Recommendation resource whose value you want to evaluate, such as acceptance or
              rejection label, action, ID, name. For example, a strategy is associated with a
              Case. Your resource can be <code>$Record.Account.Type</code>
              or <code>$Record.Account.Contact.Name</code>.</td>

          </tr>
          <tr class="">
            <td data-label="Column Header" class="slds-cell-wrap" style="vertical-align:top;" headers="d160393e91 ">
              <samp class="parmname">Operator</samp>
            </td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d160393e94 ">Select an appropriate operator for that resource, for example <code>Equals</code>, <code>Does Not
                  Equal</code>, <code>Starts With</code>, <code>Contains</code>, <code>Less Than Or
                      Equal To</code>, and <code>Is Blank</code>. The
              available operators depend on the data types associated with that resource. Data
              types include text, number, Boolean, or picklist.</td>

          </tr>
          <tr class="">
            <td data-label="Column Header" class="slds-cell-wrap" style="vertical-align:top;" headers="d160393e91 ">
              <samp class="parmname">Value</samp>
            </td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d160393e94 ">
              <p>Options: </p>
              <ul>
                <li>Select a value that’s appropriate for the recommendation resource and the
                  operator. For example, if you enter <code>$Record.Status</code> as the resource and <code>Does
                      Not Equal</code> as the operator, available values are <code>On Hold</code>, <code>Escalated</code>, <code>Closed</code>, and <code>New</code>.</li>
                <li>Manually enter a literal value.</li>
              </ul>
              <p><samp class="parmname">Resource</samp> and <samp class="parmname">Value</samp> in the same row
                must have compatible data types. </p>
              <p style="margin-bottom:0;">When you add or subtract a number from a date
                value, the date adjusts in days, not hours.</p>
            </td>

          </tr>
        </tbody>
      </table>

 
| Option | Behavior for Decision Outcomes |
| --- | --- |
| All Conditions Are Met | If one of the conditions is false, the recommendation evaluates the next outcome’s conditions. |
| Any Condition Is Met | If one of the conditions is true, the recommendation immediately takes this outcome’s path. |

![The Branch Selector dialog](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/next_best_action/nba_branch_selector.png)

For example, say you create the custom field Has\_Mobile\_Service\_\_c on the contact record. If you use $Record.Contact.Has\_Mobile\_Service\_\_c = false in a Strategy Builder expression, and you’re working with a case record, the recordID provided with the request replaces $Record when the expression resolves. The recordID replaces $Record because case records have a lookup relationship with contacts.

- Reference the context object in your formula using the $Record function.

For example, ISPICKVAL($Record.Account.Tier\_\_c, 'Premium')

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/images/icon_note.png)

Note

The Context object is the object where you plan to surface your recommendations. Choose the Context object, or change it, by editing your strategy and choosing an object under **Object Where Recommendations Display**.

- Reference fields from the Recommendation object using the plain text label name. This option is available only in Filter and Load elements, not Branch Selector elements.

For example, AcceptanceLabel = =‘Yes, please’

- Access fields returned from external connections using $nameOfExternalConnection.dataFromExternalConnection syntax. Manage your external connections through the **Manage** tab in the Toolbox.

For example, $GetCreditScoreContext.output >= 760

- Use $Request to access information the user types into forms and use that information to request specific recommendations. This option is available only on the Search and Contact Support pages in Experience Builder sites.

For example, CONTAINS($Request.search, 'paperless billing') || CONTAINS($Request.search, 'order checks') || CONTAINS($Request.search, 'new address')

For multi-select picklist fields, enter values like Includes ($Record.CarType\_\_c, ‘Audi,’‘BMW’)

#### See Also

- [Suggest Options with Recommendation Strategies](https://help.salesforce.com/s/articleView?id=platform.einstein_next_best_action.htm&release=264.0.0&type=5 "Use Einstein Next Best Action to deliver tailored recommendations at the right moment. Define strategies that apply your business logic to surface a few high-value offers such as repairs, discounts, or add-on services. Present the final recommendations in your Automation Lightning app or Experience Builder site.")
- [Formula Operators and Functions by Context](https://help.salesforce.com/s/articleView?id=platform.customize_functions.htm&language=en_US)