---
schema_version: "1"
id: 02e3691c6adda1db791723c7466f7bfe0543c540656daf9d04ca2fe4342a6d56
title: Add Custom Attributes to Penny Perfect Pricing Context
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/cg_task_admin_add_custom_attributes.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.cg_task_admin_add_custom_attributes.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: d3750fb980e4d3de3ac084850077c593a2df71c4a408de6cc4018d651248b3f0
description: Use pricing context definitions to add custom attributes for penny pricing calculations in Consumer Goods Cloud. Use custom attributes to refine condition searches or extend logic in user exits.
products:
  - Consumer Goods
release: "264"
---
# Add Custom Attributes to Penny Perfect Pricing Context

Use pricing context definitions to add custom attributes for penny pricing calculations in Consumer Goods Cloud. Use custom attributes to refine condition searches or extend logic in user exits.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience in <strong>Enterprise</strong> and <strong>Unlimited</strong> Editions that have Consumer Goods Cloud enabled</td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d17672e60">User Permissions
              Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d17672e60 ">To add custom attributes:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d17672e60 ">
              <p>CGCloud Business Admin</p>
              <p style="margin-bottom:0;">OR</p>
              <p style="margin-bottom:0;">CGCloud Retail Business Admin</p>
            </td>

          </tr>
        </tbody>
      </table>

Considerations for Custom Attributes

Keep these considerations in mind while adding custom attributes by using pricing context definition.

- Use account-related or product-related attributes only for condition searches via key attributes or key types. Salesforce doesn't support account or product-related custom attributes in user exits.
- Define only attributes that aren't already in the core context or pricing context. See [Default Context Fields](https://help.salesforce.com/s/articleView?id=ind.default_context_fields.htm&release=264.0.0&type=5 "The core pricing context includes these fields. To avoid errors, don't use these field or alias names when configuring additional context fields. Account-related and product-related attributes are for condition searches. Only order-related attributes are supported for user exits.").
- Make sure the combination of Context Section, Source, Reference Field Name, and Sales Org is unique.
- Define valid fields that exist within the source objects.
- Avoid defining field aliases that are available in the core context or pricing context definition. The combination of Context Section, Source, Field Alias, and Sales Org must be unique.
- Define up to 20 attributes per source object and sales org.
- Avoid adding attributes with the long text data type, which can slow pricing condition searches.

- **[Default Pricing Context Fields](https://help.salesforce.com/s/articleView?id=ind.default_context_fields.htm&release=264.0.0&type=5)**  
    The core pricing context includes these fields. To avoid errors, don't use these field or alias names when configuring additional context fields. Account-related and product-related attributes are for condition searches. Only order-related attributes are supported for user exits.
- **[Manage Pricing Context Definition Object Permissions](https://help.salesforce.com/s/articleView?id=ind.cg_admin_manage_pcd_permissions.htm&release=264.0.0&type=5)**  
    For the given permission sets, manually configure the object permission settings on the pricing context definition to specify the type of access that users have to the Pricing Context Definition object.

## Create a Pricing Context Definition

Define the custom attributes that you want to use in your pricing condition search or user exits.

1. From the App Launcher, find and select **Pricing Context Definition**.
2. Click **New**.
3. Enter a name and select a sales org.
4. Select a context section, such as Order Information, Account Information, or Product Information. This selection defines the pricing context section where you add the new attribute.
    
    Account-related and product-related attributes are for condition searches. Only order-related attributes are supported for user exits.
5. Select a source object.
    
    Salesforce filters the Source list based on your context section selection.
6. Enter a field name (including namespace) that matches the API name of the field in the source object.
7. Enter a field alias.
    
    The alias must be the same for the data source of the offline and online mobile apps.
8. Save your changes.

​​After you define the pricing context, define how the attributes are used.

## Custom Attribute in Pricing Condition Search

Customize your pricing logic by using custom attributes to define key attributes and key types that align with specific product or account criteria.

1. [Create a key attribute](https://help.salesforce.com/s/articleView?id=ind.cg_task_admin_create_key_atrributes.htm&release=264.0.0&type=5 "A key attribute defines a specific object field that the pricing engine uses as part of a condition record search key. Key attributes are the building blocks of key types. A key type combines multiple key attributes to define the exact combination of fields the engine uses to look up a condition record.") with Mobility Attribute as the Field Alias in Pricing Context Definition.
2. Create a key type with Distribution Category as **To All**.
3. [Create and activate a search strategy.](https://help.salesforce.com/s/articleView?id=ind.cg_task_admin_create_search_strategies.htm&release=264.0.0&type=5 "Search strategy is a set of key attribute combinations that determine pricing conditions. Depending on the key attribute combination, condition search can be specific or generic. The search strategy assigned to a pricing condition defines how a pricing condition template searches for pricing conditions. Well-designed search strategies can improve search results.")
4. [Add a search step](https://help.salesforce.com/s/articleView?id=ind.cg_task_admin_add_search_strategy_step.htm&release=264.0.0&type=5 "A search strategy consists of search strategy steps to be processed in a particular sequence. The sequence is defined by the sort column in the search strategy. The strategy steps link the key types to a search strategy. A search step can be exclusive (stop if a condition is found) or non-exclusive (executes all search steps). If multiple conditions are found, the system combines all of the conditions. For example, it’s possible to collect discounts spread over hierarchy levels."):
    1. Set Customer Hierarchy and Product Hierarchy to **No**.
    2. Select **Exclusive** to stop the search when a match is found.
5. [Prepare and integrate the pricing conditions](https://help.salesforce.com/s/articleView?id=ind.cg_concept_pricing_condition_batch_integration_synchronization.htm&release=264.0.0&type=5 "Typically, pricing conditions are stored in an Enterprise Resource Planning (ERP) system in different condition tables, such as Product key Customer key Combination of product, customer, and customer classification keys. Dynamically, for each key type or key combination a table is created. These pricing conditions are integrated from an ERP system to provide the same pricing behavior, to reuse condition data, and to handle complete calculated documents in Salesforce.").
6. [Create a pricing condition template](https://help.salesforce.com/s/articleView?id=ind.cg_task_admin_create_pricing_condition_template.htm&release=264.0.0&type=5 "The Pricing Condition Template defines various conditions, such as discounts or surcharges used in the calculation steps of a calculation schema.") and select the search strategy.
7. Create an order, calculate the price, and verify the pricing information.

## Custom Attribute in User Exit

Use custom attributes in user exits that trigger custom calculation logic during the order process.

1. Configure the user exit based on the criteria with the custom attribute.
2. Create an order, calculate the price, and verify the pricing information.

![Example](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-consumer_goods_retail_admin-264-0-0-production-enus/5bb7d7f5-119d-42d0-8596-95e762837019/images/icon_example.png)

Example This sample user exit calculates a specific base price for the Empower Cola 1,0 L PET product.

```
/**  Affected Results return the modified calculation results
    It is a JSON Object with following structure:
    currentConditionValue : 
      Holds the current condition value e.g. 19.99 for a base price
    currentCalculationBase :  
      Holds the base of the calculation ... e.g. if you order 10 items and it is a base price then the calculation base is 20
    currentCalculationResult :
      Holds the condition result e.g. 399,80 if you order 20 items with base price 19.99
    currentTotal:                     
      Holds the current value of the order position/item. For base price it is typically equal to currentCalculationResult
      But it can also be different ... e.g. for percentage discounts:
         current total before step is 200
         condition value is -10. (Percentage)
         calculation base is 200 (calculate 10% off of 200)
         calculation result -20
         current total 180 (200 - 20)
**/


var AffectedResults = {};
switch (UserExitId) {
 case "100_CalcResult_BasePrice_ext":
   if (Utils.isDefined(ProductAttributes[0].text1) && ProductAttributes[0].text1 === "Empower Cola 1,0 L PET") {
     AffectedResults.currentConditionValue = 19.99;
     AffectedResults.currentCalculationBase = 20;
     AffectedResults.currentCalculationResult = AffectedResults.currentCalculationBase * AffectedResults.currentConditionValue;
     AffectedResults.currentTotal = AffectedResults.currentCalculationResult;
   }
   break;
}
return AffectedResults;
```