AIUsecaseDefinition configures an AI Accelerator machine learning use case by connecting prediction models, feature extractors that obtain model input data, and Salesforce fields used to store scoring responses. It supports real-time predictions and configuration for sample, batch, and combined batch/realtime feature inputs.
The use case definition is the metadata component. Its models, field mappings, and feature extractors are nested definitions, not separate AIUsecaseDefinition components. Response-storage settings also differ from scorecard display settings: defining where a result can be stored does not enable saving that result.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName, usecaseName, masterLabel, creatorType
|
fullName is the inherited metadata component identity. usecaseName and masterLabel are required names for the use case. Required creatorType accepts INTERNAL_USER or SALESFORCE_ADMIN. |
aiUsecaseFieldMappings |
A collection of response-field mappings. Each mapping requires developerName, masterLabel, mappedFieldName, mappedFieldType, responseFieldName, and responseObject. |
aiUsecaseModels |
A collection of prediction-model configurations. Each model requires developerName, masterLabel, predictionDefinition, and predictionPlatform, and can contain feature extractors. |
mappedFieldType |
Distinguishes FEATURE, PREDICTION_SCORE, INSIGHT, SUGGESTION, and RECOMMENDATION data from SECONDARY_RESPONSE_RECORD_ID and RECOMMENDATION_RESPONSE_RECORD_ID mappings. The documented default is FEATURE. PREDICTION_SCORE_INPUT also appears in the exposed schema and Salesforce's example; see Documentation Inconsistencies. |
primaryResponseObject, secondaryResponseObject, recommendationResponseObject
|
Identify the primary and secondary scoring-response storage objects and the associated recommendation response object. |
shouldSaveFeatures, shouldSaveInsights, shouldSaveRecommendation, shouldSaveRequestResponse, shouldSaveScore, shouldSaveSuggestions
|
Independently enable saving each category of extracted input or prediction output. Every flag defaults to false. |
maximumInsightCount, maximumSuggestionCount
|
Limit the number of insights and suggestions returned by the scoring response. |
recommendationSource, maximumRecommendationCount
|
The source accepts Next_Best_Action_Flow or None. The count limits recommendations returned by the Next Best Action Strategy. |
suggestionImpactMinimumPct |
Filters suggestions displayed on the prediction scorecard. A suggestion's impact on improving the score must be strictly greater than this percentage. |
aiFeatureExtractors, defaultFeatureExtractor
|
Configure input extraction within a model. Salesforce documents aiFeatureExtractors as a collection and defaultFeatureExtractor as one AIFeatureExtractor. |
predictionDefinition, predictionPlatform
|
Identify the prediction definition and its platform. Platforms are Einstein_Discovery, Data_Cloud, Einstein_on_Data_Cloud, and Default. Einstein_Discovery is the documented default; Default is reserved for internal use. |
className, extractorType
|
Within a feature extractor, required className is documented as the Apex class ID, not its developer name. Required extractorType accepts APEX, JAVA, or HYBRID, with APEX as the documented default. |
featureInputType |
Required input category: Realtime_Input, Sample_Input, Batch_Input, or Batch_And_Realtime_Input. |
batchInputSourceIdentifier, batchInputSourceInformation, batchInputSourceType
|
Identify and describe the source of features computed by batch jobs. Source information can include query parameters, objects, field mappings, and filter criteria. The source type defaults to CRMA; the exposed schema also lists Data_Cloud, with a spelling discrepancy in the field documentation. |
inputContext |
Contains JSON feature context for the extractor. It can include data from an uploaded CSV file, so it can contain actual feature data rather than only configuration labels. |
Behavior and Constraints
Availability requires both the AI Accelerator admin setting and the admin setting for the product related to the use case. The org must also have the CRM Plus license and that product's CRM license.
Storage, returned results, and scorecard display
Configure response objects and field mappings separately from persistence, meaning whether Salesforce saves the data. The six shouldSave flags control saving extracted inputs and prediction outputs, not simply what appears on a scorecard. For example, a score mapping does not enable score storage while shouldSaveScore remains false.
Within each field mapping, mappedFieldName identifies the field where the scoring response is stored, while responseFieldName identifies the response object's mapped field. responseObject identifies the response-side object. Salesforce describes that object as either the configured primaryResponseObject or secondaryResponseObject, but its example introduces an exception that is not fully explained.
The returned-output limits and scorecard eligibility filter serve different purposes. maximumInsightCount and maximumSuggestionCount limit returned items; suggestionImpactMinimumPct determines which suggestions qualify for display. A suggestion whose impact equals the configured percentage does not meet the documented strictly-greater-than comparison.
Recommendations have a separate source, count, and save setting. maximumRecommendationCount limits recommendations returned by the Next Best Action Strategy, while shouldSaveRecommendation independently determines whether recommendations are saved.
Model identifiers and input extraction
Interpret predictionDefinition together with predictionPlatform. The identifier can be an external ID. For models created with Einstein Discovery, it stores the prediction definition record's developer name. Do not assume that every platform uses that same identifier format.
featureInputType explicitly identifies the input category; do not infer it solely from the prediction platform. Batch source settings describe features computed by batch jobs, while inputContext supplies feature context and can include uploaded data.
Each nested mapping, model, and feature extractor has its own required developerName and masterLabel. Those developer names identify nested definitions, not additional top-level use case components.
Deployment and Retrieval
AIUsecaseDefinition inherits fullName from Metadata as its component identity. Its files use the suffix .aiUsecaseDefinitions and are stored in the aiUsecaseDefinitions folder. The type supports the wildcard member * in a package.xml manifest.
Field mappings and models travel inside the use case definition, and feature extractors are nested within models. Their developerName values do not identify separate AIUsecaseDefinition members for retrieval or deployment.
The documented ID-based representation of an extractor's className matters for cross-org portability. Treat it as an Apex class ID rather than assuming the value is a portable Apex developer name. Likewise, interpret a model's predictionDefinition according to its platform instead of treating every value as an Einstein Discovery developer name.
Response objects, mapped fields, Apex classes, and prediction definitions are possible dependencies of the component. These relationships do not, by themselves, establish which destinations a particular use case uses or prescribe a deployment sequence.
Relationships
References occur at several levels: response-object settings belong to the use case, field references belong to its mappings, prediction-definition references belong to models, and Apex class references belong to feature extractors within models.
References
-
ApexClass:classNamewithin a model's feature extractors. -
CustomField:mappedFieldName,responseFieldNamewithin field mappings. -
CustomObject:primaryResponseObject,secondaryResponseObject,recommendationResponseObject, and each mapping'sresponseObject. -
MLPredictionDefinition:predictionDefinitionwithin a model, subject to the platform-specific identifier format.
Documentation Inconsistencies
-
Prediction-score input mapping category: Salesforce's field-table enumeration for
mappedFieldTypeomitsPREDICTION_SCORE_INPUT, although the declarative example and exposed schema include it. -
Response-object restriction: The field description restricts
responseObjectto the configured primary or secondary response object. The declarative example uses an additional object,Lead_Dmo, forPREDICTION_SCORE_INPUTmappings without explaining that category's validation rules. -
Default extractor cardinality: Salesforce documents
defaultFeatureExtractoras a singleAIFeatureExtractor, while the exposed schema represents it as an array. The array representation does not establish support for multiple default extractors. -
Batch source spelling: The exposed enumeration uses
Data_CloudforbatchInputSourceType, while Salesforce's field table spells itData Cloud. This discrepancy concerns the exact value written into metadata; it does not establish that the spellings are interchangeable.
Common Questions
Why aren't prediction scores saved after I configure field mappings?
Field mappings define where response data maps, but they do not enable saving it. shouldSaveScore defaults to false. Features, insights, suggestions, recommendations, and request responses each have separate save flags that also default to false.
What settings and licenses does AIUsecaseDefinition require?
Enable the AI Accelerator admin setting and the admin setting for the product related to the use case. The org also needs the CRM Plus license and that product's CRM license.
Does className take an Apex class name or an ID?
Salesforce documents the feature extractor's className as the Apex class ID, despite the element's name. Do not treat it as an Apex developer name when preparing a cross-org deployment.
Can AIUsecaseDefinition use both batch and real-time inputs?
Yes. featureInputType accepts Batch_And_Realtime_Input, as well as Batch_Input, Realtime_Input, and Sample_Input. The input category is configured explicitly rather than inferred solely from the model platform.
How do I retrieve AIUsecaseDefinition components?
Use AIUsecaseDefinition in the metadata manifest; wildcard member * is supported. Component files are stored in aiUsecaseDefinitions with the suffix .aiUsecaseDefinitions. Models, mappings, and feature extractors are included as nested definitions rather than separate use case members.