---
schema_version: "1"
id: dd0e4dc48fe02cf7c53b64b9e34c8275bb47dc5618d18e57618fd0272e93a5da
title: Create a Context Definition
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/context_service_create_context_definitions.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.context_service_create_context_definitions.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: faabd5bcedc725349d6a5aa7e1c3953d4741d4a0d145001659c683b28ce581e5
description: Create a context definition by choosing nodes, defining their relationship, adding attributes, and applying context tags.
products:
  - Industry Solutions
  - Cross Cloud
release: "264"
---
# Create a Context Definition

Create a context definition by choosing nodes, defining their relationship, adding attributes, and applying context tags.

### 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</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Developer</strong>, <strong>Enterprise</strong>, <strong>Professional</strong>, and <strong>Unlimited</strong> editions for Industries clouds where Context Service is 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="d5447e72">User Permissions Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d5447e72 ">To create context definitions:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d5447e72 ">Context Service Admin</td>

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

Use the context definition that meets your business requirements. For example, to optimize the pricing performance, use a context definition to cache the data required at multiple steps of a pricing procedure. Identify the data required by various pricing elements and define a structure by creating nodes and attributes. When you use the pricing procedure, these nodes, attributes, and context tags help you get the right data from the context definition. You can set a transposable node to handle a scenario where you want to use a single attribute to store different values.

![Important](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-context_service-264-0-0-production-enus/e9dc37f3-cb53-4bc1-be8b-b6873099d0be/images/icon_important.png)

Important

- All nodes, attributes, and context tag names must be unique. The names must begin with a letter, and can't contain any special characters except for underscores. The names can’t begin with a number, can’t include spaces, can’t end with an underscore, and can’t contain two consecutive underscores.
- Standard definitions are inherently Active, which means you can’t deactivate or delete them. You can only extend or clone a standard definition.
- You can activate, clone, edit, or delete a custom context definition.
- The Effective From and Effective To dates determine how long the context definition stays active. If you don’t specify an Effective To date, the context definition stays active forever. If you don't provide an Effective From date, the context definition is effective from the current date and time.

1. From Setup, in the Quick Find box, enter Context Service, and then select **Context Definitions**.
2. Click **New**.
3. Specify the context definition details.
    
    1. Name your context definition.
    2. In Description, enter other details about the context definition, if necessary.
    3. Select the effective date range.
    4. In Time to Live, select how long you want the data that’s loaded in your context instance to live.
        
        ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-context_service-264-0-0-production-enus/e9dc37f3-cb53-4bc1-be8b-b6873099d0be/images/icon_note.png)
        
        Note The duration that you specify here takes effect in certain apps that can support longer Time to Live. Usually the context definition lives for the duration of your request, which is typically a few seconds.
    5. If you want other definitions to refer this definition, select **Reference Definition**.
    6. To link two other definitions that act as reference definitions, click **+Add Reference Definition**.
    
    ![Context Definition Details](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-context_service-264-0-0-production-enus/e9dc37f3-cb53-4bc1-be8b-b6873099d0be/context_service/images/Addnewdefinition.png)
4. Click **Next**.
5. Configure a structure to define a relationship between the nodes by adding child and sibling nodes, as necessary.
    
    ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-context_service-264-0-0-production-enus/e9dc37f3-cb53-4bc1-be8b-b6873099d0be/images/icon_note.png)
    
    Note A reference data type attribute is generated when you define a parent-child relationship between nodes.
6. Specify the node details.
    
    1. Give your node a name.
    2. To add child nodes, click ![Child Node icon](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-context_service-264-0-0-production-enus/e9dc37f3-cb53-4bc1-be8b-b6873099d0be/context_service/images/context_serevice_child_node.png).
    3. To add sibling nodes, click ![Sibling node](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-context_service-264-0-0-production-enus/e9dc37f3-cb53-4bc1-be8b-b6873099d0be/context_service/images/context_serevice_sibling_node.png).
    4. To convert the node’s record to a field name, click ![More icon](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-context_service-264-0-0-production-enus/e9dc37f3-cb53-4bc1-be8b-b6873099d0be/context_service/images/context_serevice_more_icon.png), and select **Mark as Transposable**.
    5. To remove a node, click ![More icon](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-context_service-264-0-0-production-enus/e9dc37f3-cb53-4bc1-be8b-b6873099d0be/context_service/images/context_serevice_more_icon.png), and select **Delete**.
    6. To automatically generate and manage data for nodes and attributes, select **System Information Node**.
    
    ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-context_service-264-0-0-production-enus/e9dc37f3-cb53-4bc1-be8b-b6873099d0be/images/icon_note.png)
    
    Note
    
    - The parent-child nodes help determine the hierarchy in which data is consumed.
    - The deletion of a parent node deletes the child nodes associated with it.
    
    ![Add Nodes](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-context_service-264-0-0-production-enus/e9dc37f3-cb53-4bc1-be8b-b6873099d0be/context_service/images/AddNode.png)
7. Click **Next**.
8. Add attributes for each node by choosing an input type, the data type, and values if you have a key-value pair.
    
    <table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
              <thead class="slds-text-title_caps ">
                <tr><th class="slds-cell-wrap" scope="col" id="d5447e356">Attribute Type</th>
                <th class="slds-cell-wrap" scope="col" id="d5447e359">Description</th>
                <th class="slds-cell-wrap" scope="col" id="d5447e362">Persistence</th>
              </tr></thead>
              <tbody><tr class="">
                <td class="slds-cell-wrap" data-label="Attribute Type" headers="d5447e356">INPUT</td>
                <td class="slds-cell-wrap" data-label="Description" headers="d5447e359">Read-Only <p>Select INPUT type when data is hydrated by Context Service
                    (e.g., Salesforce objects) and only needs to be read by the consuming
                    application.</p>
                </td>
                <td class="slds-cell-wrap" data-label="Persistence" headers="d5447e362">Typically not persisted in the database, except for REFERENCE
                  attributes.</td>
              </tr>
              <tr class="">
                <td class="slds-cell-wrap" data-label="Attribute Type" headers="d5447e356">OUTPUT</td>
                <td class="slds-cell-wrap" data-label="Description" headers="d5447e359">Write <p>Select OUTPUT type when data must be written to or modified by the
                    consuming application or a subsequent process.</p>
                </td>
                <td class="slds-cell-wrap" data-label="Persistence" headers="d5447e362">Data is written back to from context definition to Salesforce
                  Objects.</td>
              </tr>
              <tr class="">
                <td class="slds-cell-wrap" data-label="Attribute Type" headers="d5447e356">INPUT OUTPUT</td>
                <td class="slds-cell-wrap" data-label="Description" headers="d5447e359">Read and Write <p>Select the INPUT OUTPUT type when you want to hydrate the
                    context definition initially, but the consuming application must update that
                    data later in the process.</p>
                </td>
                <td class="slds-cell-wrap" data-label="Persistence" headers="d5447e362">Data is written back to from context definition to Salesforce
                  Objects.</td>
              </tr>
            </tbody></table>
    
    ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-context_service-264-0-0-production-enus/e9dc37f3-cb53-4bc1-be8b-b6873099d0be/images/icon_note.png)
    
    Note REFERENCE attributes, which establish links between nodes, can only have the INPUT type. Attributes marked as transient are explicitly skipped during context persistence, so their values are stored temporarily in the context without being saved to the database.
9. Click **Add Attributes** and specify the attribute’s details.
    
    ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-context_service-264-0-0-production-enus/e9dc37f3-cb53-4bc1-be8b-b6873099d0be/images/icon_note.png)
    
    Note
    
    - A key and value column appears for an attribute only if you marked its node as transposable.
    - Context Service returns all data and time attributes in the UTC time zone. The consuming application can convert it to any time zone that suits the user or organization.
    - To store changes made to an attribute temporarily in the cache without saving them to the database,select **Transient** on the Add Attributes page.
    
    ![Add Attributes](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-context_service-264-0-0-production-enus/e9dc37f3-cb53-4bc1-be8b-b6873099d0be/context_service/images/ctx_Add_Attributes.png)
10. Click **Next**.
11. Generate the context tags.
    
    - To generate tags for all the nodes and attributes at one go, select **Generate All Tags**.
    
    - To generate a tag for a single node or attribute, select **Generate Node Tags**.
    
    - To generate new tags for the selected node and its attributes, including nodes and attributes with tags, select **Regenerate All**.
    
    - To generate tags only for the selected node and attributes without tags, select **Retain and Generate**.
12. On the Create Attribute tags page, click **Generate All Tags** or **Generate Node Tags**.
13. In the Generate Tags window, click **Regenerate All** or **Retain and Generate**.![Generate Context Tags](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-context_service-264-0-0-production-enus/e9dc37f3-cb53-4bc1-be8b-b6873099d0be/context_service/images/generatetags_withnewbuttons.png)
14. Save your context definition.

The created context definition is listed on the Context Definitions page, under the Custom Definitions tab. To start the mapping process, click the context definition. After you complete the mapping, activate it.

#### See Also

- [Add Context Mapping](https://help.salesforce.com/s/articleView?id=ind.context_service_add_context_mapping.htm&release=264.0.0&type=5 "To make sure that your nodes and attributes are updated with the right input data, Salesforce objects, or context definition objects, create a mapping structure for your context definition.")
- [Activate a Context Definition](https://help.salesforce.com/s/articleView?id=ind.context_service_activate_context_definition.htm&release=264.0.0&type=5 "To start using the context definition, you must first activate it. After it’s activated, your consuming application can execute various procedures using context definitions.")
- [Context Service Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.industries_reference.meta/industries_reference/context_service_overview.htm)
- [Context Service API (DELETE, GET)](https://developer.salesforce.com/docs/atlas.en-us.industries_reference.meta/industries_reference/context_service_overview.htm)
- [Financial Services Cloud Admin Guide](https://help.salesforce.com/s/articleView?id=ind.consumption_framework_create_and_map_context_definitions.htm&type=5&language=en_US)
- [Business Rule Engine - Decision Matrices for Developers](https://help.salesforce.com/s/articleView?id=ind.consumption_framework_create_and_map_context_definitions.htm&type=5&language=en_US)