---
schema_version: "1"
id: f0ba8afdb843e01910d40f2f1cd0b24aa4e0a5f5d007776f496ab62c3d35c37c
title: ForecastingSourceDefinition
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/object_reference/sforce_api_objects_forecastingsourcedefinition.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_forecastingsourcedefinition.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 75cf1137adf734b7e6a8ce9caa3d1959bc0215bee97fabc2891e11ab3df1b269
description: Represents the object, measure, date type, and hierarchy that a forecast uses to project sales. This object is available in API version 52.0 and later.
---
# ForecastingSourceDefinition

Represents the object, measure, date type, and hierarchy that a forecast uses to project sales. This object is available in API version 52.0 and later.

![Note](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/images/icon_note.png)

#### Note

The information in this topic applies only to forecast types created in Summer ’21 and later.

## Supported Calls

create(), delete(), describeSObjects(), query(), retrieve(), update(), upsert()

## Fields

| Field | Details |
| --- | --- |
| CategoryField | 
Type

picklist

Properties

Create, Filter, Group, Nillable, Restricted picklist, Sort

Description

Name of the forecast category that is associated with the forecast type.

Possible values are:

- Opportunity.ForecastCategoryName





 |
| DateField | 

Type

picklist

Properties

Create, Filter, Group, Nillable, Restricted picklist, Sort

Description

Field that is used for the forecast type’s date type. For example, the CloseDate field on Opportunity is used for opportunity close date-based forecast types.

Possible values are:

- Opportunity.CloseDate
- OpportunityLineItem.ServiceDate
- OpportunityLineItemSchedule.ScheduleDate





 |
| DeveloperName | 

Type

string

Properties

Create, Filter, Group, Sort, Update

Description

The developer name of the forecasting source definition.

![Note](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/images/icon_note.png)

#### Note

Only users with View DeveloperName OR View Setup and Configuration permission can view, group, sort, and filter this field.















 |
| FamilyField | 

Type

picklist

Properties

Create, Filter, Group, Nillable, Restricted picklist, Sort

Description

Use this field to group forecasts by product family. Possible values are:

- Product2.Family





 |
| Language | 

Type

picklist

Properties

Create, Defaulted on create, Filter, Group, Nillable, Restricted picklist, Sort, Update

Description

Language of the forecasting source definition. For example, English.



 |
| MasterLabel | 

Type

string

Properties

Create, Filter, Group, Sort, Update

Description

Required. Controlling label for this forecasting source definition.



 |
| MeasureField | 

Type

picklist

Properties

Create, Filter, Group, Nillable, Restricted picklist, Sort

Description

Field that is used for the forecast type’s measure. For example, the Amount field on Opportunity is associated with revenue-based forecast types.

Possible values are\*:

- Opportunity.Amount
- Opportunity.Custom
- Opportunity.TotalOpportunityQuantity
- OpportunityLineItem.Custom
- OpportunityLineItem.Quantity
- OpportunityLineItem.TotalPrice
- OpportunityLineItemSchedule.Custom
- OpportunityLineItemSchedule.Quantity
- OpportunityLineItemSchedule.Revenue
- OpportunitySplit.Custom
- OpportunitySplit.SplitAmount

\*Where Custom represents the name of the custom field that a forecast type’s measure is based on. Example: Use Megawatts\_\_c to forecast energy consumption.



 |
| SourceObject | 

Type

picklist

Properties

Create, Filter, Group, Nillable, Restricted picklist, Sort

Description

Object associated with this forecasting source definition.

Possible values are:

- Opportunity
- OpportunityLineItem
- OpportunityLineItemSchedule
- OpportunitySplit
- Product2





 |
| Territory2Field | 

Type

picklist

Properties

Create, Filter, Group, Nillable, Restricted picklist, Sort

Description

For a territory-based forecast type, indicates the field that is used for territory information.

Possible values are:

- Opportunity.Territory2Id

For user role-based forecast types, this value is null.



 |
| UserField | 

Type

picklist

Properties

Create, Filter, Group, Nillable, Restricted picklist, Sort

Description

Specifies who owns the forecast.

Possible values are:

- Opportunity.OwnerId
- OpportunitySplit.SplitOwnerId





 |

## Usage

Use ForecastingSourceDefinition to define a forecast type’s structure. A forecasting source definition is joined via ForecastingTypeSource to ForecastingType.

In this example, a user role-based forecast type called Custom Amount Forecast is based on the Amount and Close Date fields on opportunities.

ForecastingType type = new  sforce.SObject("ForecastingType");
type.DeveloperName = "Custom\_Amount\_Forecast";
type.MasterLabel = "Custom Amount Forecast";
type.IsAmount = true;
type.IsQuantity = false;
type.RoleType = "R";
type.DateType = "OpportunityCloseDate";
String typeId = insert(type);

ForecastingSourceDefinition sourceDefinition = new sforce.SObject("ForecastingSourceDefinition")
sourceDefinition.DeveloperName = "Custom Amount Source";
sourceDefinition.MasterLabel = "Custom\_Amount\_Source";
sourceDefinition.SourceObject = "Opportunity";
sourceDefinition.MeasureField = "Opportunity.Amount";
sourceDefinition.DateField = "Opportunity.CloseDate";
sourceDefinition.UserField = "Opportunity.OwnerId";
sourceDefinition.CategoryField = "Opportunity.ForecastCategoryName";
String sourceDefinitionId = insert(sourceDefinition);

ForecastingTypeSource typeSource = new sforce.SObject("ForecastingTypeSource");
typeSource.MasterLabel = "Custom Amount Type Source";
typeSource.DeveloperName = "Custom\_Amount\_Type\_Source";
typeSource.ForecastingTypeId = typeId;
typeSource.ForecastingSourceDefinitionId = sourceDefinitionId;
typeSource.SourceGroup = 1;
insert(typeSource);