MLDataDefinition defines the data used to create a model: the source object, included and excluded fields, training records, and records eligible to receive prediction scores. It controls the model's data scope, not its algorithm.
Field selection and record eligibility are separate settings. Including a field does not define which records train the model or receive scores, and a training filter does not serve as a scoring filter.
Key Elements
Elements shown under MLFilter belong to the embedded filter structure, not directly to the top-level definition.
| Element | What the Element Controls |
|---|---|
developerName |
Required, org-unique internal name. It must begin with a letter, contain only alphanumeric characters and underscores, contain no spaces or consecutive underscores, and not end with an underscore. |
entityDeveloperName |
Required developer name of the source object. It cannot change after the MLDataDefinition entity is created. |
type |
Required data-definition role. Documented values are Candidate, Interaction, Prediction, and Recipient. It cannot change after the model is created. |
includedFields, excludedFields
|
Lists of fields included in or excluded from the model. These select fields, not records. |
trainingFilter |
An MLFilter selecting the records that make up the training set. |
scoringFilter |
An MLFilter selecting records to which prediction scores are written. |
segmentFilter |
Further restricts both training and scoring data when combined with both trainingFilter and scoringFilter. |
MLFilter.filterName |
Required name of the filter. |
MLFilter.lhFilter, MLFilter.lhPredictionField, MLFilter.lhValue; corresponding rhFilter, rhPredictionField, rhValue
|
Left-hand and right-hand operands. Each side uses only one alternative: a nested filter, a prediction field, or a literal value. |
MLFilter.operation |
Required operator. Supports Boolean composition, comparisons, arithmetic, string operations, null checks, and membership operations. |
MLFilter.lhType, MLFilter.rhType
|
Identify the type of a supplied literal value: Boolean, Comparison, Currency, Date, DateTime, Number, String, Supplier, or Varchar. |
MLFilter.lhUnit, MLFilter.rhUnit
|
Specify units when a filter operand is supplied: Milliseconds, Seconds, Minutes, Hours, Days, Weeks, Months, or Years. |
MLFilter.sortOrder |
Controls the order in which expressions are evaluated, not merely their display order. |
joinFields |
Contains MLField structures but is reserved for future use. |
parentDefinitionDevName |
Reserved for future use. Its presence does not establish usable parent-definition behavior. |
Behavior and Constraints
Source object, role, and name have different constraints
The source-object restriction applies when the MLDataDefinition entity is created: entityDeveloperName cannot be updated afterward. The restriction on type applies after the model is created. These are different lifecycle boundaries; changing the source object is not an ordinary update to an existing definition.
Viewing, grouping, sorting, or filtering developerName requires either View DeveloperName or View Setup and Configuration permission. This requirement applies specifically to that field; it is not a general grant of access to model data.
Training and scoring populations are independent
trainingFilter selects training records, while scoringFilter selects records that receive prediction scores. A restriction present only in one filter must not be treated as a restriction on the other population.
When segmentFilter is combined with both filters, it further restricts both populations. For example, a segment filter can limit both training and scoring to records in a particular region.
Filters support nested expressions
Each MLFilter uses a left-hand operand, an operator, and a right-hand operand. Only one of lhFilter, lhPredictionField, or lhValue is populated on the left; only one of rhFilter, rhPredictionField, or rhValue is populated on the right. Nested lhFilter and rhFilter structures support compound expressions rather than only flat field-to-value comparisons.
The allowed operation values are:
- Boolean composition:
And,Or,Not. - Comparisons:
LessThan,LessThanOrEqual,GreaterThan,GreaterThanOrEqual,Equals,NotEquals. - Arithmetic:
Add,Subtract,Multiply,Divide. - String operations:
StartsWith,EndsWith,Contains,Concat,DoesNotContain. - Null checks and membership operations:
IsNull,IsNotNull,Between,In.
Use the operand type elements to describe literal values and the unit elements when a filter operand is supplied. sortOrder determines expression evaluation order.
Exposed join structures are reserved
joinFields contains MLField structures with required entity, field, and type members. However, joinFields itself is reserved for future use, as are MLField.relatedField and MLField.relationType. Their exposed structure does not establish usable join behavior.
Deployment and Retrieval
MLDataDefinition components use the .mlDataDefinition suffix and reside in the mlDataDefinitions folder. The type extends Metadata and inherits fullName. A package.xml manifest can use * to select all components of this type.
An update cannot change entityDeveloperName after the definition entity is created, or type after the model is created. These restrictions matter when comparing an existing target definition with a deployment that changes its source object or role.
Field dependency checks must cover more than includedFields and excludedFields. The three filters, including recursively nested filters, can reference fields through lhPredictionField and rhPredictionField.
A community report also links prediction configuration to a managed-package uninstall block involving packaged fields. In that case, field-usage checks and downloaded-metadata text searches did not identify the cause; see Reported Issues.
Relationships
The definition connects to its source object and to fields selected for modeling or used in filter expressions. The object and field connections exposed under joinFields remain reserved structures, not documented usable joins.
References
-
CustomObject:entityDeveloperName;entitywithin the reservedjoinFieldsstructure. -
CustomField:includedFields,excludedFields;lhPredictionFieldandrhPredictionFieldwithinscoringFilter,segmentFilter,trainingFilter, and their nested filters;fieldwithin the reservedjoinFieldsstructure.
Documentation Inconsistencies
The documented allowed-value list for type contains Candidate, Interaction, Prediction, and Recipient. An alternate exposed element schema also lists Generative, which is not covered by that documented list.
Salesforce defines includedFields and excludedFields as string lists, while the alternate element schema represents each as a single string. Salesforce defines scoringFilter, segmentFilter, and trainingFilter as individual MLFilter values, while that schema represents them as arrays. These are representation discrepancies, not documented alternative filtering behaviors.
Reported Issues
-
A managed-package uninstall was reportedly blocked by an Einstein Prediction Builder prediction using all Contact fields. In November 2024, an admin reported that the prediction created dependencies involving packaged Contact custom fields. Field-usage checks and downloaded-metadata text searches had not revealed the cause. The admin also lacked permission to follow the dependency links and identified the linked runtime
MLDataDefinitionrecords by IDs beginning with0ga. The reported cause was prediction configuration, not the similarly named Contact record type; those record IDs were not metadata developer names. Read the reported diagnosis.
Common Questions
Can I change the source object or type of an MLDataDefinition?
entityDeveloperName cannot change after the definition entity is created. type cannot change after the model is created. The two restrictions take effect at different lifecycle boundaries.
Does trainingFilter also restrict which records receive prediction scores?
No. trainingFilter selects training records, and scoringFilter selects records that receive scores. When combined with both, segmentFilter further restricts both populations.
Where are MLDataDefinition files stored, and can I retrieve them with a wildcard?
They are stored in mlDataDefinitions with the .mlDataDefinition suffix. The type supports * in the package.xml manifest.
Which MLDataDefinition settings can reference custom fields?
includedFields and excludedFields select fields directly. lhPredictionField and rhPredictionField can reference fields throughout the training, scoring, and segment filters, including nested filters. The reserved joinFields structure also exposes a field reference.
Can Einstein Prediction Builder prevent a managed package from being uninstalled?
A November 2024 community report describes that outcome when a prediction used all Contact fields, including packaged custom fields. The linked dependencies were runtime MLDataDefinition records, and ordinary field-usage checks and metadata text searches had not exposed the cause.