---
schema_version: "1"
id: 5ada18ecec64f16b6c7ceb8504f743c44638ddc8fa8b71fc6fe971ca24b3634d
title: Scenarios Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/retail_api/TPM_Scenarios.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 167093f7b82f7f5197f7749140cb227e9e5b0cbb8fe5987628a53acd567fbc86
description: This APEX class provides programmatic access to the TPM Promotion Scenario information used in the Promotion. Scenarios define selectable sets of Promotion Level Manual Inputs overrides to simulate different combinations of active/inactive tactics and KPI overrides in a TPM Promotion. A TPM_Scenarios structure can contain up to five scenarios information. Index must be an scenario index between 1 and 5 (included) Adds a parameter to the scenario parameters of the selected scenario. The required attributes are the scenario index, the KPI Name to set (must be a Scenario KPI defined on the Promotion Template), the numeric value of the KPI and if the parameter is already applied (If applied, UI will not re-apply the value when loading the scenario information. If not applied, when loading the scenario, UI will apply the value of the parameter to the total of the KPI) .Index must be an scenario index between 1 and 5 (included) Returns all the scenario parameters for the selected scenario. Serializes the scenarios information into a generic object. Useful for usage on remote calls.Index must be an scenario index between 1 and 5 (included) Serializes the parameters information for the selected scenario into a generic object. Useful for usage on remote calls. Index must be an scenario index between 1 and 5 (included) Serializes the manual inputs information for the selected scenario into a generic object. Useful for usage on remote calls. Loads the serialized scenarios information into the current instance. The current instance will be cleared and the scenarios represented by the payload will be loaded.Index must be an scenario index between 1 and 5 (included) Serializes the parameters information for the selected scenario into a String used for storage. Serializes the scenarios information into a Sstring used for storage.Index must be an scenario index between 1 and 5 (included) Serializes the manual inputs information for the selected scenario into a String used for storage. Creates an empty scenario sctructure.Loads the scenarios information from the parameter generic object. The current instance will be cleared and the scenarios represented by the payload will be loaded.Index must be an scenario index between 1 and 5 (included) Sets the parameter manual inputs as manual inputs for the selected scenario. Index must be an scenario index between 1 and 5 (included) Returns the manual inputs for the selected scenario.Removes all information for the five possible scenarios.Index must be an scenario index between 1 and 5 (included) Removes the passed in scenario parameter from the parameters of the selected scenario. If the ScenarioParameter is not part of the scenario, nothing is removed.
---
# Scenarios Class

This APEX class provides programmatic access to the TPM Promotion Scenario information used in the Promotion. Scenarios define selectable sets of Promotion Level Manual Inputs overrides to simulate different combinations of active/inactive tactics and KPI overrides in a TPM Promotion. A TPM\_Scenarios structure can contain up to five scenarios information.

## Namespace

cgcloud

- **[TPM\_Scenarios Methods](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm#tpm_global_secnarios_method.)**

## TPM\_Scenarios Methods

The following are methods for TPM\_Scenarios.

- **[global ScenarioParameter addScenarioParameter](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm#global_tpm_scenarios)**  
    Index must be an scenario index between 1 and 5 (included) Adds a parameter to the scenario parameters of the selected scenario. The required attributes are the scenario index, the KPI Name to set (must be a Scenario KPI defined on the Promotion Template), the numeric value of the KPI and if the parameter is already applied (If applied, UI will not re-apply the value when loading the scenario information. If not applied, when loading the scenario, UI will apply the value of the parameter to the total of the KPI) .
- **[global List<ScenarioParameter> getScenarioParameters](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm#unique_531904407)**  
    Index must be an scenario index between 1 and 5 (included) Returns all the scenario parameters for the selected scenario.
- **[global Map<String, Object> toGenericObject](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm#unique_1109272756)**  
    Serializes the scenarios information into a generic object. Useful for usage on remote calls.
- **[global Object toGenericObjectParameters](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm#unique_620312286)**  
    Index must be an scenario index between 1 and 5 (included) Serializes the parameters information for the selected scenario into a generic object. Useful for usage on remote calls.
- **[global Object toGenericObjectManualInputs](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm#unique_707408170)**  
    Index must be an scenario index between 1 and 5 (included) Serializes the manual inputs information for the selected scenario into a generic object. Useful for usage on remote calls.
- **[global TPM\_Scenarios load](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm#unique_1437942627)**  
    Loads the serialized scenarios information into the current instance. The current instance will be cleared and the scenarios represented by the payload will be loaded.
- **[global String toJSONParameters](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm#unique_928194766)**  
    Index must be an scenario index between 1 and 5 (included) Serializes the parameters information for the selected scenario into a String used for storage.
- **[global String toJSON](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm#unique_1048821060)**  
    Serializes the scenarios information into a Sstring used for storage.
- **[global String toJSONManualInputs](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm#unique_1477310318)**  
    Index must be an scenario index between 1 and 5 (included) Serializes the manual inputs information for the selected scenario into a String used for storage.
- **[global TPM\_Scenarios](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm#unique_271292663)**  
    Creates an empty scenario sctructure.
- **[global TPM\_Scenarios load](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm#unique_1417293650)**  
    Loads the scenarios information from the parameter generic object. The current instance will be cleared and the scenarios represented by the payload will be loaded.
- **[global TPM\_Scenarios setScenarioManualInputs](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm#unique_1294652276)**  
    Index must be an scenario index between 1 and 5 (included) Sets the parameter manual inputs as manual inputs for the selected scenario.
- **[global TPM\_ManualInputs getScenarioManualInputs](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm#unique_535621801)**  
    Index must be an scenario index between 1 and 5 (included) Returns the manual inputs for the selected scenario.
- **[global void clear](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm#unique_616081215)**  
    Removes all information for the five possible scenarios.
- **[global void removeScenarioParameter](https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/TPM_Scenarios.htm#unique_1859747356)**  
    Index must be an scenario index between 1 and 5 (included) Removes the passed in scenario parameter from the parameters of the selected scenario. If the ScenarioParameter is not part of the scenario, nothing is removed.

### global ScenarioParameter addScenarioParameter

Index must be an scenario index between 1 and 5 (included) Adds a parameter to the scenario parameters of the selected scenario. The required attributes are the scenario index, the KPI Name to set (must be a Scenario KPI defined on the Promotion Template), the numeric value of the KPI and if the parameter is already applied (If applied, UI will not re-apply the value when loading the scenario information. If not applied, when loading the scenario, UI will apply the value of the parameter to the total of the KPI) .

#### API Version

55

#### Signature

global ScenarioParameter addScenarioParameter(Integer scenarioIdx, String kpiName, Decimal value, Boolean applied)

### global List<ScenarioParameter> getScenarioParameters

Index must be an scenario index between 1 and 5 (included) Returns all the scenario parameters for the selected scenario.

#### API Version

55

#### Signature

global List<ScenarioParameter> getScenarioParameters(Integer scenarioIdx)

### global Map<String, Object> toGenericObject

Serializes the scenarios information into a generic object. Useful for usage on remote calls.

#### API Version

55

#### Signature

global Map<String, Object\> toGenericObject()

### global Object toGenericObjectParameters

Index must be an scenario index between 1 and 5 (included) Serializes the parameters information for the selected scenario into a generic object. Useful for usage on remote calls.

#### API Version

55

#### Signature

global Object toGenericObjectParameters(Integer idx)

### global Object toGenericObjectManualInputs

Index must be an scenario index between 1 and 5 (included) Serializes the manual inputs information for the selected scenario into a generic object. Useful for usage on remote calls.

#### API Version

55

#### Signature

global Object toGenericObjectManualInputs(Integer idx)

### global TPM\_Scenarios load

Loads the serialized scenarios information into the current instance. The current instance will be cleared and the scenarios represented by the payload will be loaded.

#### API Version

55

#### Signature

global TPM\_Scenarios load(String payload)

### global String toJSONParameters

Index must be an scenario index between 1 and 5 (included) Serializes the parameters information for the selected scenario into a String used for storage.

#### API Version

55

#### Signature

global String toJSONParameters(Integer idx)

### global String toJSON

Serializes the scenarios information into a Sstring used for storage.

#### API Version

55

#### Signature

global String toJSON()

### global String toJSONManualInputs

Index must be an scenario index between 1 and 5 (included) Serializes the manual inputs information for the selected scenario into a String used for storage.

#### API Version

55

#### Signature

global String toJSONManualInputs(Integer idx)

### global TPM\_Scenarios

Creates an empty scenario sctructure.

#### API Version

55

#### Signature

global TPM\_Scenarios()

### global TPM\_Scenarios load

Loads the scenarios information from the parameter generic object. The current instance will be cleared and the scenarios represented by the payload will be loaded.

#### API Version

55

#### Signature

global TPM\_Scenarios load(Object data)

### global TPM\_Scenarios setScenarioManualInputs

Index must be an scenario index between 1 and 5 (included) Sets the parameter manual inputs as manual inputs for the selected scenario.

#### API Version

55

#### Signature

global TPM\_Scenarios setScenarioManualInputs(Integer scenarioIdx, TPM\_ManualInputs manualInputs)

### global TPM\_ManualInputs getScenarioManualInputs

Index must be an scenario index between 1 and 5 (included) Returns the manual inputs for the selected scenario.

#### API Version

55

#### Signature

global TPM\_ManualInputs getScenarioManualInputs(Integer scenarioIdx)

### global void clear

Removes all information for the five possible scenarios.

#### API Version

55

#### Signature

global void clear()

### global void removeScenarioParameter

Index must be an scenario index between 1 and 5 (included) Removes the passed in scenario parameter from the parameters of the selected scenario. If the ScenarioParameter is not part of the scenario, nothing is removed.

#### API Version

55

#### Signature

global void removeScenarioParameter(Integer scenarioIdx, ScenarioParameter param)