---
schema_version: "1"
id: 6bd53da48bf15589a1440ecf0ce1c6d0d9ed105b08f6f016eca96907f56404cf
title: AIUsecaseDefinition
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_meta/meta_aiusecasedefinition.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_aiusecasedefinition.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: bbe052742350d1ef73f3624e2a33eb4e50b9fddbed50c2e59f9b8296f41bbab9
description: Represents a collection of fields in your Salesforce org used to define a machine learning use case and get real-time predictions.
---
# AIUsecaseDefinition

Represents a collection of fields in your Salesforce org used to define a machine learning use case and get real-time predictions.

![Important](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/images/icon_note_important.png)

#### Important

Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations.

## Parent Type

This type extends the [Metadata](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/metadata.htm "The base class for all metadata types. You can’t edit this object. A component is an instance of a metadata type.") metadata type and inherits its fullName field.

## File Suffix and Directory Location

AIUsecaseDefinition components have the suffix .aiUsecaseDefinitions and are stored in the aiUsecaseDefinitions folder.

## Version

AIUsecaseDefinition components are available in API version 56.0 and later.

## Special Access Rules

The AIUsecaseDefinition object is available when the admin settings for AI Accelerator and for the product related to the use case are enabled. The Salesforce org must have the CRM Plus license and the product’s CRM license.

## Fields

| Field Name | Description |
| --- | --- |
| aiUsecaseFieldMappings | 
Field Type

[AIUsecaseFieldMapping\[\]](#AIUsecaseFieldMapping)

Description

The field mappings for the use case definition. Each use case definition can have multiple field mappings.



 |
| aiUsecaseModels | 

Field Type

[AIUsecaseModel\[\]](#AIUsecaseModel)

Description

The models for the use case definition. Each use case definition can have multiple use case models.



 |
| creatorType | 

Field Type

CreatorType (enumeration of type string)

Description

Required.

The type of user who created the use case definition that's used by AI Accelerator. Valid values are:

- INTERNAL\_USER
- SALESFORCE\_ADMIN

Available in API version 57.0 and later.



 |
| masterLabel | 

Field Type

string

Description

Required.

A user-friendly name for the use case definition, which is defined when the use case definition is created.



 |
| maximumInsightCount | 

Field Type

int

Description

The maximum number of insights returned by the scoring response.



 |
| maximumRecommendationCount | 

Field Type

int

Description

The maximum number of recommendations returned by the Next Best Action Strategy.



 |
| maximumSuggestionCount | 

Field Type

int

Description

The maximum number of suggestions returned by the scoring response.



 |
| primaryResponseObject | 

Field Type

string

Description

The primary object in which the scoring response is stored based on the specified field mapping.



 |
| recommendationResponseObject | 

Field Type

string

Description

The recommendation response object associated with the use case definition.



 |
| recommendationSource | 

Field Type

RcmdSourceType (enumeration of type string)

Description

The tool or platform that generates recommendations. Valid values are:

- Next\_Best\_Action\_Flow
- None

Available in API version 57.0 and later.



 |
| secondaryResponseObject | 

Field Type

string

Description

The object in which the scoring response is stored based on the specified field mapping.



 |
| shouldSaveFeatures | 

Field Type

boolean

Description

Indicates whether to save the features extracted for the scoring request (true) or not (false).

The default value is false.



 |
| shouldSaveInsights | 

Field Type

boolean

Description

Indicates whether to save the prediction insights that are used to generate the score (true) or not (false).

The default value is false.



 |
| shouldSaveRecommendation | 

Field Type

boolean

Description

Indicates whether to save the recommendation (true) or not (false).

The default value is false.



 |
| shouldSaveRequestResponse | 

Field Type

boolean

Description

Indicates whether to save the request response (true) or not (false).

The default value is false.



 |
| shouldSaveScore | 

Field Type

boolean

Description

Indicates whether to save the prediction score (true) or not (false).

The default value is false.



 |
| shouldSaveSuggestions | 

Field Type

boolean

Description

Indicates whether to save the suggestions for improving the prediction score (true) or not (false).

The default value is false.



 |
| suggestionImpactMinimumPct | 

Field Type

int

Description

The minimum eligible percentage for improving the existing prediction score based on the suggestions. Suggestions with an impact greater than the specified percentage on the score are displayed on the prediction scorecard.



 |
| usecaseName | 

Field Type

string

Description

Required.

The name of the use case definition.



 |

## AIUsecaseFieldMapping

Represents information about the field mapping to store extracted features, prediction scores, prediction insights, and use case suggestions in the response object.

| Field Name | Description |
| --- | --- |
| developerName | 
Field Type

string

Description

The unique name for the field mapping in the use case definition.

Required. The unique name of the object in the API. This name can contain only underscores and alphanumeric characters, and must be unique in your org. It must begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. In managed packages, this field prevents naming conflicts on package installations. With this field, a developer can change the object’s name in a managed package and the changes are reflected in a subscriber’s organization. Label is **Record Type Name**.



 |
| mappedFieldName | 

Field Type

string

Description

Required.

The name of the field where the scoring response is stored.



 |
| mappedFieldType | 

Field Type

MappedFieldType (enumeration of type string)

Description

Required.

The type of the mapped field.

Valid values are:

- FEATURE
- PREDICTION\_SCORE
- INSIGHT
- SUGGESTION
- SECONDARY\_RESPONSE\_RECORD\_ID
- RECOMMENDATION\_RESPONSE\_RECORD\_ID
- RECOMMENDATION

The default value is FEATURE.



 |
| masterLabel | 

Field Type

string

Description

Required.

A user-friendly name for the use case field mapping, which is defined when the field mapping is created.



 |
| responseFieldName | 

Field Type

string

Description

Required.

The name of the response object’s field that’s mapped to the field storing the score.



 |
| responseObject | 

Field Type

string

Description

Required.

The object whose field is mapped to the field storing the score. It’s either the PrimaryResponseObject or the SecondaryResponseObject specified in the AIUsecaseDefinition object.



 |
| sequenceNumber | 

Field Type

int

Description

The sequence number for the information stored in the field mapping.



 |

## AIUsecaseModel

Represents information about the machine learning models that generate predictions for your use case.

| Field Name | Description |
| --- | --- |
| aiFeatureExtractors | 
Field Type

[AIFeatureExtractor\[\]](#AIFeatureExtractor)

Description

The AI feature extractors to retrieve the input data.



 |
| defaultFeatureExtractor | 

Field Type

[AIFeatureExtractor](#AIFeatureExtractor)

Description

The default AI feature extractor to retrieve the input data.



 |
| developerName | 

Field Type

string

Description

The unique name for the use case model.

Required. The unique name of the object in the API. This name can contain only underscores and alphanumeric characters, and must be unique in your org. It must begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. In managed packages, this field prevents naming conflicts on package installations. With this field, a developer can change the object’s name in a managed package and the changes are reflected in a subscriber’s organization. Label is **Record Type Name**.



 |
| masterLabel | 

Field Type

string

Description

Required.

A user-friendly name for the use case model, which is defined when the use case model is created.



 |
| predictionDefinition | 

Field Type

string

Description

The unique identifier of the prediction definition that’s related to the use case model. This identifier can be an external ID. If you use Einstein Discovery to create models, the predictionDefinition field stores the developer name of the record.



 |
| predictionPlatform | 

Field Type

PredictionPlatform (enumeration of type string)

Description

Required.

The platform on which the machine learning model is created and deployed. Valid values are:

- Data\_Cloud
- Default—For internal use only.
- Einstein\_Discovery
- Einstein\_on\_Data\_Cloud—Available in API version 63.0 and later.

The default value is Einstein\_Discovery. Available in API version 57.0 and later.



 |

## AIFeatureExtractor

Represents information about the feature extractor that’s used to retrieve the input data for the use case model that’s used to generate predictions.

| Field Name | Description |
| --- | --- |
| batchInputSourceIdentifier | 
Field Type

string

Description

The identifier of the input source of the features computed by batch jobs, which can be used by a model for generating predictions. Available in API version 57.0 and later.



 |
| batchInputSourceInformation | 

Field Type

string

Description

The information about the batch input source, including query parameters, objects, field mappings, and filter criteria. Available in API version 63.0 and later.



 |
| batchInputSourceType | 

Field Type

BatchInputSourceType (enumeration of type string)

Description

The input source of the features computed in batch jobs.

Possible values are:

- CRMA
- Data Cloud

The default value is CRMA.



 |
| className | 

Field Type

string

Description

Required.

The ID of the Apex class created for the feature extractor.



 |
| developerName | 

Field Type

string

Description

The unique name for the feature extractor.

Required. The unique name of the object in the API. This name can contain only underscores and alphanumeric characters, and must be unique in your org. It must begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores. In managed packages, this field prevents naming conflicts on package installations. With this field, a developer can change the object’s name in a managed package and the changes are reflected in a subscriber’s organization. Label is **Record Type Name**.



 |
| extractorType | 

Field Type

ExtractorType (enumeration of type string)

Description

Required.

The type of the feature extractor.

Valid values are:

- APEX
- JAVA
- HYBRID

The default value is APEX.



 |
| featureInputType | 

Field Type

string

Description

Required.

The type of feature input that’s used in generating predictions. Valid values are:

- Realtime\_Input
- Sample\_Input
- Batch\_Input
- Batch\_And\_Realtime\_Input

Available in API version 57.0 and later.



 |
| inputContext | 

Field Type

string

Description

The JSON file with features that act as context for the feature extractor. This data can also include the data in the uploaded CSV file. Available in API version 57.0 and later.



 |
| masterLabel | 

Field Type

string

Description

Required.

A user-friendly name for the feature extractor, which is defined when the feature extractor is created.



 |

## Declarative Metadata Sample Definition

The following is an example of an AIUsecaseDefinition component.

<?xml version="1.0" encoding="UTF-8"?>
<AIUsecaseDefinition xmlns="http://soap.sforce.com/2006/04/metadata">
    <aiUsecaseFieldMappings\>
        <developerName\>DevNamee1</developerName\>
        <mappedFieldName\>Name</mappedFieldName\>
        <mappedFieldType\>INSIGHT</mappedFieldType\>
        <masterLabel\>DevName</masterLabel\>
        <responseFieldName\>AnnualRevenue</responseFieldName\>
        <responseObject\>Lead</responseObject\>
        <sequenceNumber\>2</sequenceNumber\>
    </aiUsecaseFieldMappings\>
    <aiUsecaseFieldMappings\>
        <developerName\>DevNamee2</developerName\>
        <mappedFieldName\>Value</mappedFieldName\>
        <mappedFieldType\>INSIGHT</mappedFieldType\>
        <masterLabel\>DevName</masterLabel\>
        <responseFieldName\>Id</responseFieldName\>
        <responseObject\>Account</responseObject\>
        <sequenceNumber\>2</sequenceNumber\>
    </aiUsecaseFieldMappings\>
    <aiUsecaseFieldMappings\>
        <developerName\>DevNamee3</developerName\>
        <mappedFieldName\>Score</mappedFieldName\>
        <mappedFieldType\>PREDICTION\_SCORE</mappedFieldType\>
        <masterLabel\>DevName</masterLabel\>
        <responseFieldName\>Company</responseFieldName\>
        <responseObject\>Lead</responseObject\>
    </aiUsecaseFieldMappings\>
    <aiUsecaseFieldMappings\>
        <developerName\>DevNamee4</developerName\>
        <mappedFieldName\>RecordId</mappedFieldName\>
        <mappedFieldType\>SECONDARY\_RESPONSE\_RECORD\_ID</mappedFieldType\>
        <masterLabel\>DevName</masterLabel\>
        <responseFieldName\>Address</responseFieldName\>
        <responseObject\>Lead</responseObject\>
        <joinFieldInformation\>joinFieldInformation</joinFieldInformation\>
    </aiUsecaseFieldMappings\>
    <aiUsecaseFieldMappings\>
        <developerName\>DevName5</developerName\>
        <mappedFieldName\>DevName4</mappedFieldName\>
        <mappedFieldType\>PREDICTION\_SCORE\_INPUT</mappedFieldType\>
        <masterLabel\>DevName</masterLabel\>
        <responseFieldName\>Address</responseFieldName\>
        <responseObject\>Lead\_Dmo</responseObject\>
        <joinFieldInformation\>{"recordIdField":"Value2","recordIdObject":"Value1","recordJoinRelation":"Value3"}</joinFieldInformation\>
    </aiUsecaseFieldMappings\>
    <aiUsecaseFieldMappings\>
        <developerName\>DevName6</developerName\>
        <mappedFieldName\>DevName5</mappedFieldName\>
        <mappedFieldType\>PREDICTION\_SCORE\_INPUT</mappedFieldType\>
        <masterLabel\>DevName</masterLabel\>
        <responseFieldName\>Address</responseFieldName\>
        <responseObject\>Lead\_Dmo</responseObject\>
        <joinFieldInformation\>{"recordIdField":"Value2","recordIdObject":"Value1","recordJoinRelation":"Value3"}</joinFieldInformation\>
        <additionalFieldInformation\>{"customPredictionAttributes":\[{"id":1,"fieldLabel":"Label 1","sourceField":"Total\_Spend\_c\_\_c"},{"id":2,"fieldLabel":"Label 2","sourceField":"Predicted\_Churned2\_recommendation\_impact\_\_c"}\]}</additionalFieldInformation\>
        <customPredictionLabel\>%%SCORE%%</customPredictionLabel\>
    </aiUsecaseFieldMappings\>
    <aiUsecaseModels\>
        <aiFeatureExtractors\>
            <className\>01pxx0000004X2CAAU</className\>
            <extractorType\>APEX</extractorType\>
            <developerName\>DevNamee2</developerName\>
            <masterLabel\>DevName</masterLabel\>
            <featureInputType\>Realtime\_Input</featureInputType\>
            <inputContext>"{columnNames=\[column1, column2\], rawData=\[S, 315090\]}"</inputContext\>
            <batchInputSourceIdentifier\>DatasetName</batchInputSourceIdentifier\>
            <batchInputSourceType\>CRMA</batchInputSourceType\>
            <batchInputSourceInformation\>{"streamingTransformName":"SDT\_Name","recordIdField":"fieldname","featureFieldsMapping":{"feature1":"field1","feature2":"field2"},"streaminTransformLabel":"SDT\_Label","batchInputSourceLabel":"DMO\_Label"}</batchInputSourceInformation\>
        </aiFeatureExtractors\>
        <defaultFeatureExtractor\>
            <className\>01pxx0000004X0aAAE</className\>
            <extractorType\>APEX</extractorType\>
            <developerName\>DevNamee1</developerName\>
            <masterLabel\>DevName</masterLabel\>
            <featureInputType\>Realtime\_Input</featureInputType\>
            <inputContext>"{columnNames=\[column1, column2\], rawData=\[S, 315090\]}"</inputContext\>
            <batchInputSourceIdentifier\>DatasetName</batchInputSourceIdentifier\>
            <batchInputSourceType\>CRMA</batchInputSourceType\>
            <batchInputSourceInformation\>{"streamingTransformName":"SDT\_Name","recordIdField":"fieldname","featureFieldsMapping":{"feature1":"field1","feature2":"field2"},"streaminTransformLabel":"SDT\_Label","batchInputSourceLabel":"DMO\_Label"}</batchInputSourceInformation\>
        </defaultFeatureExtractor\>
        <developerName\>DevNamee1</developerName\>
        <masterLabel\>DevName</masterLabel\>
        <predictionDefinition\>PredictionDefinitionD</predictionDefinition\>
        <predictionPlatform\>Einstein\_Discovery</predictionPlatform\>
        <arePredctGenInRealTime\>true</arePredctGenInRealTime\>
    </aiUsecaseModels\>
    <aiUsecaseModels\>
        <developerName\>DevNamee2</developerName\>
        <masterLabel\>DevName</masterLabel\>
        <predictionDefinition\>PredictionDefinitionBA</predictionDefinition\>
        <predictionPlatform\>Einstein\_Discovery</predictionPlatform\>
        <arePredctGenInRealTime\>true</arePredctGenInRealTime\>
    </aiUsecaseModels\>
    <aiUsecaseModels\>
        <developerName\>DevNamee3</developerName\>
        <masterLabel\>DevName</masterLabel\>
        <predictionDefinition\>PredictionDefinitionCA</predictionDefinition\>
        <predictionPlatform\>Einstein\_Discovery</predictionPlatform\>
        <arePredctGenInRealTime\>true</arePredctGenInRealTime\>
    </aiUsecaseModels\>
    <aiUsecaseModels\>
        <developerName\>DevName4</developerName\>
        <masterLabel\>DevName</masterLabel\>
        <predictionDefinition\>Model1</predictionDefinition\>
        <predictionPlatform\>Data\_Cloud</predictionPlatform\>
        <arePredctGenInRealTime\>false</arePredctGenInRealTime\>
    </aiUsecaseModels\>
    <aiUsecaseModels\>
        <developerName\>DevName5</developerName\>
        <masterLabel\>DevName</masterLabel\>
        <predictionDefinition\>Model1</predictionDefinition\>
        <predictionPlatform\>Einstein\_on\_Data\_Cloud</predictionPlatform\>
        <arePredctGenInRealTime\>false</arePredctGenInRealTime\>
    </aiUsecaseModels\>
    <masterLabel\>DevName</masterLabel\>
    <maximumInsightCount\>3</maximumInsightCount\>
    <maximumSuggestionCount\>3</maximumSuggestionCount\>
    <maximumRecommendationCount\>3</maximumRecommendationCount\>
    <primaryResponseObject\>Lead</primaryResponseObject\>
    <secondaryResponseObject\>Account</secondaryResponseObject\>
    <recommendationResponseObject\>Contact</recommendationResponseObject\>
    <shouldSaveFeatures\>true</shouldSaveFeatures\>
    <shouldSaveInsights\>true</shouldSaveInsights\>
    <shouldSaveRecommendation\>false</shouldSaveRecommendation\>
    <shouldSaveRequestResponse\>false</shouldSaveRequestResponse\>
    <shouldSaveScore\>true</shouldSaveScore\>
    <shouldSaveSuggestions\>true</shouldSaveSuggestions\>
    <suggestionImpactMinimumPct\>50</suggestionImpactMinimumPct\>
    <usecaseName\>FTestSampleMLUsecase</usecaseName\>
    <recommendationSource\>Next\_Best\_Action\_Flow</recommendationSource\>
    <creatorType\>INTERNAL\_USER</creatorType\>
</AIUsecaseDefinition\>

The following is an example package.xml that references the previous definition.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types\>
        <members\>\*</members\>
        <name\>\*AIUsecaseDefinition\*</name\>
    </types\>
    <version\>68.0</version\>
</Package\>

## 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](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/file_based_zip_file.htm "The deploy() and retrieve() calls are used to deploy and retrieve a .zip file. Within the .zip file is a project manifest (package.xml) that lists what to retrieve or deploy, and one or more XML components that are organized into folders.").