Newer Version Available

This content describes an older version of this product. View Latest

RecommendationStrategy

Represents a recommendation strategy. Recommendation strategies are applications, similar to data flows, that determine a set of recommendations to be delivered to the client through data retrieval, branching, and logic operations.

File Suffix and Directory Location

RecommendationStrategy components have the suffix .recommendationStrategy and are stored in the recommendationStrategies folder.

Version

RecommendationStrategy components are available in API version 45.0 and later.

Special Access Rules

Metadata access for the RecommendationStrategy type is backed by the ManageRecommendationStrategies user permission.

Fields

Field Name Field Type Description
actionContext StrategyAction[] An array of action contexts used by the strategy.
contextRecordType string The sObject type of the $record used by the flow.
description string Description of the recommendation strategy.
filter StrategyNodeFilter[] An array of filter nodes.
if StrategyNodeIf[] An array of if nodes.
invocableAction StrategyNodeInvocableAction[] An array of Apex invocable action nodes. Available in API version 46.0 and later.
isTemplate boolean Indicates whether the recommendation strategy is a template (true) or not (false). When installed from managed packages, recommendation strategies can’t be viewed or cloned by subscribers because of intellectual property (IP) protection. But when those recommendation strategies are templates, subscribers can open them in a builder, clone them, and customize the clones. The default value of this field is false. Available in API version 47.0 and later.
label string Required. Label for the flow.
map StrategyNodeMap[] An array of map nodes. Available in API version 46.0 and later.
mutuallyExclusive StrategyNodeExclusive[] An array of mutuallyExclusive nodes.
onBehalfOfExpression string Formula expression defining the intended target of the recommendations (in other words, the Contact associated with a Case). Mainly used for reaction tracking.
recommendationLimit StrategyNodeRecommendationLimit[] An array of recommendation limit nodes.
recommendationLoad StrategyNodeRecommendationLoad[] An array of recommendation load nodes.
sort StrategyNodeSort[] An array of sort nodes.
union StrategyNodeUnion[] An array of union nodes.

StrategyNodeBase

Base class for all strategy nodes. This is an abstract class.

Field Name Field Type Description
childNode string Array of child node names, in order of execution.
description string Description of the node.
label string Label of the node.
name string Required. Unique name of the node.

StrategyAction

Defines a call to an invocable action from the strategy. Results are used by decision elements in the strategy.

Field Name Field Type Description
action string Required. The name or id of the InvocableAction to execute.
argument StrategyActionArg[] List of strategy action arguments.
description string Description of the strategy.
label string Label for the strategy action.
name string Required. Unique name of the strategy action, which is referenced by decisioning elements in the strategy.
type InvocableActionType (enumeration of type string) Required. Type of the invocable action. See the enum InvocableActionType.

StrategyActionArg

Defines arguments passed to invocable actions associated with a strategy action.

Field Name Field Type Description
name string Required. Unique name for the parameter to pass to the invocable action.
value string Required. A Salesforce formula expression that is evaluated with the result being used as the parameter value for the Strategy Action.

StrategyNodeUnionBase

Base class for nodes that perform a union of their children. Union nodes combine the outputs of their children to form the input to themselves. StrategyNodeUnionBase extends StrategyNodeBase and inherits all of its fields. This is an abstract class.

Field Name Field Type Description
limit int Maximum number of results to output.

StrategyNodeFilter

Defines a filter element that filters recommendations. It extends StrategyNodeUnionBase and inherits all its fields.

Field Name Field Type Description
expression string Required. A formula expression that results in a boolean value when executed on each recommendation in the node’s input. Inputs that result in true form the output, and inputs that result in false are excluded.

StrategyNodeIf

Selects specific children to execute and combines their results. Executes and returns results of children based on the array of child node expressions. Extends StrategyNodeUnionBase and inherits all of its fields.

Field Name Field Type Description
childNodeExpression IfExpression[] Array of if expressions.
onlyFirstMatch boolean If true, selects only the results from the matching child. If false, selects and combines results from all matching children. The default value is false.

IfExpression

Expression used by StrategyNodeIf.

Field Name Field Type Description
childName string Required. Name of child to match.
expression string Required. Formula expression returning true or false.

StrategyNodeInvocableAction

Defines an element that calls an Apex invocable action to generate or enhance a list of recommendations. It extends StrategyNodeUnionBase and inherits all its fields.

Field Name Field Type Description
action string Required. The name of the invocable action to execute.
argument StrategyNodeInvocableActionArg[] List of arguments that are passed to the invocable action.
isGenerator boolean Required. If true, the UI displays the Generate element. If false, the UI displays the Enhance element. Defaults to false.
type InvocableActionType (enumeration of type string) Required. Type of the invocable action. See the enum InvocableActionType. Valid value is apex.

StrategyNodeInvocableActionArg

Defines arguments passed to an Apex invocable action that generates or enhances a list of recommendations.

Field Name Field Type Description
name string Required. Unique name for the parameter to pass to the invocable action. The name must match a parameter that's defined in the invocable action.
value string Required. A Salesforce formula expression that is evaluated with the result used as the parameter value for the action.

StrategyNodeRecommendationLimit

Filters out recommendations that have already been accepted or rejected. Extends StrategyNodeUnionBase and inherits all of its fields.

Field Name Field Type Description
filterMode StrategyReactionType (enumeration of type string)

Available reactions to filter out. The valid values are:

  • Accepted
  • Rejected
lookbackDuration int Number of days to search back.
maxRecommendationCount int Maximum number of times recommendation has been accepted or rejected.

StrategyNodeRecommendationLoad

Retrieves Recommendation objects. Extends StrategyNodeUnionBase and inherits all of its fields.

Field Name Field Type Description
condition RecommendationLoadCondition[] Array of conditions specifying which recommendations to load.
conditionLogic string Logic to combine conditions, either AND or OR. All conditions are combined (not mixed). For example: Cond1 AND Cond2 AND Cond3.
object string Required. Specifies the API name of the sObject from which recommendations are loaded. For example, the field references Account or MyCustomObject__c and not a specific record of that object. Available in API version 48.0 and later.
sortField StrategyNodeSortField The field to sort on. Available in API version 48.0 and later.

RecommendationLoadCondition

Represents a condition used as part of the query constructed by StrategyNodeRecommendationLoad.

Field Name Field Type Description
field string Required. Any field from Recommendation BPO (SOAP) object.
operator RecommendationConditionOperator (enumeration of type string) Required.

Valid values are:

  • EQUALS
  • GREATER_THAN
  • GREATER_THAN_OR_EQUAL_TO
  • LESS_THAN
  • LESS_THAN_OR_EQUAL_TO
  • NOT_EQUALS
  • LIKE
  • STARTS_WITH
  • ENDS_WITH=
  • CONTAINS
value RecommendationConditionValue Required. Constant value to use in query.

RecommendationConditionValue

Represents a value used as part of a RecommendationCondition.

Field Name Field Type Description
type RecommendationConditionValueType (enumeration of type string) Required.

Valid values are:

  • TEXT
  • NUMBER
  • BOOLEAN
  • DATE
  • DATE_TIME
  • TIME
value string Required. The constant value.

StrategyNodeSortField

Defines the field to sort on for StrategyNodeSort and StrategyNodeRecommendationLoad.

Field Name Field Type Description
name string Required. Name of the field to sort.
nullsFirst boolean If true, null values are sorted to the beginning of the list. Defaults to false.
order SortOrder (enumeration of type string)

Order in which the list is sorted. Defaults to Asc. Valid values are:

  • Asc (ascending)
  • Desc (descending)

StrategyNodeSort

Sorts the recommendations. Extends StrategyNodeUnionBase and inherits all of its fields.

Field Name Field Type Description
field StrategyNodeSortField Required. Field to sort on.

StrategyNodeUnion

StrategyNodeUnion combines the output of all its child nodes. StrategyNodeUnion is a concrete implementation of StrategtNodeUnionBase and inherits all its fields.

StrategyNodeMap

Set recommendation fields with values. Extends StrategyNodeUnionBase and inherits all of its fields.

Field Name Field Type Description
mapExpression MapExpression[] List of MaxExpressions.

StrategyNodeExclusive

Returns results from the first child node that has results and no other. Extends StrategyNodeUnionBase and inherits all its fields.

MapExpression

Sets the value for a recommendation field used by the strategy.

Field Name Field Type Description
expression string Required. A formula expression that results in a valid value supported by the data type specified in the type field.
name string Required. Recommendation field name that the expression sets the value for.
type string Required. The data type of the value resulting from the value in the expression field.

Valid values are:

  • BOOLEAN
  • CURRENCY
  • DATE
  • DOUBLE
  • DATE_TIME
  • INTEGER
  • LONG
  • PERCENT
  • TEXT
  • TIME

Declarative Metadata Sample Definition

The following is an example of a RecommendationStrategy component that references the previous definition.

1<?xml version="1.0" encoding="UTF-8"?>
2<RecommendationStrategy xmlns="http://soap.sforce.com/2006/04/metadata">
3    <contextRecordType>Asset</contextRecordType>
4    <description>Hills Brothers Coffee strategy to handle machine down incidents</description>
5    <if>
6        <childNode>IfNoEscaladeOrBetterSupport</childNode>
7        <childNode>IfModel</childNode>
8        <description>If Machine Down</description>
9        <label>RootNode</label>
10        <name>RootNode</name>
11        <childNodeExpression>
12            <childName>IfModel</childName>
13            <expression>ISPICKVAL($Record.Status, &quot;OutOfOrder&quot;)</expression>
14        </childNodeExpression>
15        <childNodeExpression>
16            <childName>IfNoEscaladeOrBetterSupport</childName>
17            <expression>ISPICKVAL($Record.Status, &quot;OutOfOrder&quot;)</expression>
18        </childNodeExpression>
19        <onlyFirstMatch>false</onlyFirstMatch>
20    </if>
21    <if>
22        <childNode>LoadEscalade</childNode>
23        <description>If Customer does not have escalade support plan</description>
24        <label>IfNoEscaladeOrBetterSupport</label>
25        <name>IfNoEscaladeOrBetterSupport</name>
26        <childNodeExpression>
27            <childName>LoadEscalade</childName>
28            <expression>NOT(ISPICKVAL($Record.Account.SLA__c, &quot;Gold&quot;) || ISPICKVAL($Record.Account.SLA__c, &quot;Platinum&quot;))</expression>
29        </childNodeExpression>
30        <onlyFirstMatch>false</onlyFirstMatch>
31    </if>
32    <if>
33        <childNode>LoadMiniDiagnostic</childNode>
34        <childNode>LoadMaxiDiagnostic</childNode>
35        <description>If Machine Model switch node</description>
36        <label>IfModel</label>
37        <name>IfModel</name>
38        <childNodeExpression>
39            <childName>LoadMiniDiagnostic</childName>
40            <expression>$Record.Product2.Name == &quot;Mini Coffee Roaster&quot;</expression>
41        </childNodeExpression>
42        <childNodeExpression>
43            <childName>LoadMaxiDiagnostic</childName>
44            <expression>$Record.Product2.Name == &quot;Maxi Coffee Roaster&quot;</expression>
45        </childNodeExpression>
46        <onlyFirstMatch>false</onlyFirstMatch>
47    </if>
48    <label>HillsBrothersCoffee</label>
49    <recommendationLoad>
50        <description>Load upgrade to escalade support plan</description>
51        <label>LoadEscalade</label>
52        <name>LoadEscalade</name>
53        <condition>
54            <field>Name</field>
55            <operator>EQUALS</operator>
56            <value>
57                <type>TEXT</type>
58                <value>Upgrade your Maintenance Package</value>
59            </value>
60        </condition>
61        <conditionLogic>and</conditionLogic>
62    </recommendationLoad>
63    <recommendationLoad>
64        <description>Load Mini Coffee Roaster Diagnostic Troubleshooting proposition</description>
65        <label>LoadMiniDiagnostic</label>
66        <name>LoadMiniDiagnostic</name>
67        <condition>
68            <field>Name</field>
69            <operator>EQUALS</operator>
70            <value>
71                <type>TEXT</type>
72                <value>Mini Coffee Roaster Diagnostic Troubleshooting</value>
73            </value>
74        </condition>
75        <conditionLogic>and</conditionLogic>
76    </recommendationLoad>
77    <recommendationLoad>
78        <description>Load Maxi Coffee Roaster Diagnostic Troubleshooting proposition</description>
79        <label>LoadMaxiDiagnostic</label>
80        <name>LoadMaxiDiagnostic</name>
81        <condition>
82            <field>Name</field>
83            <operator>EQUALS</operator>
84            <value>
85                <type>TEXT</type>
86                <value>Maxi Coffee Roaster Diagnostic Troubleshooting</value>
87            </value>
88        </condition>
89        <conditionLogic>and</conditionLogic>
90    </recommendationLoad>
91    <union>
92        <childNode>RootNode</childNode>
93        <label>Output</label>
94        <name>Output</name>
95    </union>
96    <invocableAction>
97        <action>MyInvocableApexClass</action>
98        <isGenerator>true</isGenerator>
99        <type>apex</type>
100        <argument>
101            <name>MyNameParam</name>
102            <value>$User.FirstName</value>
103        </argument>
104        <argument>
105            <name>MyIdParam</name>
106            <value>$Record.Id</value>
107        </argument>
108    </invocableAction>
109    <map>
110        <expression>
111            <name>Name</name>
112            <expression>'Hello' & $User.FirstName</expression>
113            <type>TEXT</type>
114        </expression>
115        <expression>
116            <name>MyDynamicField</name>
117            <expression>Id == $Record.Id</expression>
118            <type>BOOLEAN</type>
119        </expression>
120    </map>
121</RecommendationStrategy>

Wildcard Support in the Manifest File

This metadata type supports the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.