DiscoveryGoal defines an Einstein Discovery prediction definition: a container associated with one or more deployed models. Multiple models serve different segments of the data, and a prediction definition can contain up to ten active models. Package Manager lists this metadata type as "Discovery Prediction".
A prediction definition is not the model asset itself. Its nested deployedModels entries configure deployment, input mappings, segmentation, and suggested improvements, while each entry's aiModel identifies a separate DiscoveryAIModel asset. The definition also controls prediction writeback, outcome monitoring, and model-card documentation.
Key Elements
| Element | What the Element Controls |
|---|---|
active |
Whether the prediction definition is active. This is separate from each deployed model's active state. |
deployedModels.active |
Whether an individual deployed model is active. |
deployedModels.aiModel |
The full name of the DiscoveryAIModel being deployed. |
deployedModels.filters |
Segmentation filters used to select a model for an input row. The first matching model supplies the prediction; a model without filters matches every input row. |
deployedModels.fieldMappings |
Maps model variables to Salesforce fields or CRM Analytics dataset columns. Each mapping's sourceType is SalesforceField or AnalyticsDatasetField. |
deployedModels.classificationThreshold |
The threshold for binary classification only. This value is null for regression models. |
predictionType |
The prediction category: Regression, Classification, MulticlassClassification, or Unknown. Classification means binary classification. |
subscribedEntity |
The Salesforce object associated with the prediction definition, including the object that contains the writeback field. |
pushbackField |
The custom field used for automated prediction writeback. Removing this element also deletes that field from the Salesforce object. |
pushbackType |
Must be AiRecordInsight. The enumerated value Direct is unsupported and reserved for future use. |
outcome |
Identifies the outcome variable, its label, mapped field, and optimization goal. goal allows Maximize, Minimize, and None; None is reserved for future use. |
terminalStateFilters |
Defines when an observation has reached its actual outcome and qualifies for predicted-versus-observed performance monitoring. |
deployedModels.prescribableFields |
Identifies actionable model fields associated with suggested improvements. Its name identifies a model variable, not automatically a Salesforce field. |
deployedModels.prescribableFields.customDefinitions |
Selects custom improvement text through filters and generates it from template. Default text applies when no custom definitions are supplied or a definition omits its template. |
modelCards |
Holds model-card sections, titles, and contact details for the prediction definition, separately from deployed model configuration. |
Behavior and Constraints
Activation and model selection
DiscoveryGoal.active describes the prediction definition's state. Each deployedModels.active flag describes one deployed model's state. They operate at different scopes and must not be interpreted interchangeably.
Model selection uses the segmentation filters in deployedModels.filters. For a given input row, the first model whose filters match supplies the prediction. An unfiltered model matches all rows, so overlapping filters and the position of an unfiltered catch-all model can change which model supplies a prediction.
deployedModels.name names the nested deployed model, and deployedModels.label is its label in Model Manager. Neither replaces aiModel, which holds the full name of the referenced model asset.
Regression represents a numeric prediction, Classification represents binary classification, and MulticlassClassification represents multiclass classification. The deployed model's classificationThreshold applies only to binary classification; it is null for regression models.
Input mappings and join keys
The meaning of a field mapping depends on sourceType:
- For
SalesforceField,modelFieldidentifies the model variable andmappedFieldidentifies its Salesforce input field. - For
AnalyticsDatasetField,modelFieldidentifies the model variable,sourceidentifies the CRM Analytics dataset, andmappedFieldidentifies a column in that dataset.sourceFieldJoinKeyidentifies the dataset lookup column used for the join.
source and sourceFieldJoinKey are documented as null for non-dataset mappings. The documentation conflicts on whether sobjectFieldJoinKey must be null for dataset mappings; do not clear it solely on the basis of that description. The conflict is detailed below.
Resolve field names in their nesting context. outcome.field names the outcome model variable, and prescribableFields.name names an actionable model variable. A mappedField can instead identify a Salesforce field or a dataset column, depending on its context.
Outcome monitoring and filter scope
outcome identifies the outcome variable and its mapped field. terminalStateFilters defines when an observation has attained its terminal state, meaning that its actual outcome has been reached. Einstein Discovery compares predicted outcomes with observed outcomes to determine model accuracy, so these filters affect when observations qualify for performance monitoring.
Filters have different purposes depending on where they appear:
-
deployedModels.filtersselects a model for prediction. -
terminalStateFiltersidentifies observations that have reached their actual outcome. -
prescribableFields.customDefinitions.filtersselects custom improvement text.
These filter contexts do not make every field a Salesforce field reference. For example, a segmentation filter can use a Salesforce field, while a custom improvement filter can use a model variable.
A filter contains field, operator, type, and values. Filter field types include Text, Number, Date, DateTime, and Boolean. Each filter value has its own type, either Constant or PlaceHolder; this is distinct from the filter's field data type.
Improvement text and model cards
Within a deployed model, prescribableFields identifies actionable fields associated with suggested improvements. Its customDefinitions can use filters to select text and a template to generate that text. Default improvement text is used when no custom definitions are supplied or when a custom definition omits its template. These filters do not route input rows to deployed models.
modelCards belongs to the prediction definition rather than to an individual deployed model. Each card can contain sections, a title in label, and contact details in contactName and contactEmail.
Deployment and Retrieval
DiscoveryGoal files are stored in the discovery folder and use the .goal suffix. In package.xml, use DiscoveryGoal as the metadata type name. The manifest supports individual members and the * wildcard.
The nested deployedModels entries are deployment configurations within the goal, not separate DiscoveryAIModel assets. Their aiModel values reference those assets by full name. Other dependencies depend on the configuration: the subscribed Salesforce object, Salesforce fields used by mappings or filters, the writeback custom field, and CRM Analytics datasets used by dataset mappings.
Removing pushbackField is destructive. Removing it from the goal metadata also deletes the corresponding custom field from the Salesforce object named by subscribedEntity. This is not merely removal of a reference or disabling of automated writeback.
pushbackType must be AiRecordInsight. Do not treat the presence of Direct in the enumeration as support for deploying that value; it is unsupported and reserved for future use.
Relationships
The main dependencies connect the prediction definition to model assets, Salesforce objects and fields, and CRM Analytics datasets. Interpret field references in their nesting context: model-variable names and dataset-column names are not automatically Salesforce field dependencies.
References
-
DiscoveryAIModel:aiModelwithindeployedModels, using the model asset's full name. -
CustomObject:subscribedEntity, identifying the associated Salesforce object. -
CustomField:pushbackField;mappedFieldwhen it identifies a Salesforce field;sobjectFieldJoinKeyfor an object-side join field; and filterfieldvalues when they identify Salesforce fields. Do not interpretoutcome.fieldorprescribableFields.nameas Salesforce field references solely because of their element names. -
WaveDataset:sourcewithin dataset-basedfieldMappings. The associatedmappedFieldandsourceFieldJoinKeyidentify dataset columns.
Documentation Inconsistencies
-
Outcome direction descriptions are reversed. The published description of
outcome.goalvalueMaximizesays to minimize the outcome, whileMinimizesays to maximize it. This wording conflict does not establish that runtime optimization direction is inverted.Noneis explicitly reserved for future use. -
The dataset join-key description conflicts with the example. The description of
sobjectFieldJoinKeysays it is null whensourceTypeisAnalyticsDatasetField. However, the documented dataset-mapping example setssobjectFieldJoinKeytoOpportunity.Name, alongside datasetsourcevalueemployeesandsourceFieldJoinKeyvalueName. The description therefore does not establish a reliable requirement to clear the object-side join key from dataset mappings.
Common Questions
What happens if I remove pushbackField from DiscoveryGoal?
Salesforce also deletes the corresponding custom field from the object identified by subscribedEntity. Removing pushbackField is a destructive field change, not just a way to disable writeback.
How does DiscoveryGoal choose between multiple deployed models?
It uses the first model whose segmentation filters match the input row. A model without filters matches every row, so overlapping filters and the position of an unfiltered model affect selection.
How do I retrieve DiscoveryGoal metadata?
Use metadata type DiscoveryGoal in package.xml, with individual members or *. Files use the .goal suffix in the discovery folder. Package Manager displays the type as "Discovery Prediction".
Are all DiscoveryGoal field names Salesforce field dependencies?
No. outcome.field and prescribableFields.name identify model variables. In input mappings, mappedField identifies a Salesforce field for SalesforceField mappings or a dataset column for AnalyticsDatasetField mappings. Filter field names also depend on their nesting context.
Are terminalStateFilters the same as deployed model filters?
No. terminalStateFilters identifies when actual outcomes have been reached for performance monitoring. deployedModels.filters selects which model supplies a prediction. Filters inside custom improvement definitions select improvement text instead.