---
schema_version: "1"
id: eff1b8e915f6d9d48ad9fafd433d35ff661bc68acb888f5d8c4f261968adf286
title: Create a Segmentation Rule Definition in Retail Execution
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/cg_task_admin_create_segmentation_rule_definition.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.cg_task_admin_create_segmentation_rule_definition.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 980142157f655278bad749b57f497f83f287665041ccbb3bd5d008c09cf1b679
description: A rule definition is a Salesforce Object Query Language (SOQL) query defined as a string with variables specified in a specific syntax with bound attributes. To create a segmentation rule, create a segmentation rule definition. When creating a segmentation rule, enter a value for the variables defined in the rule definition.
products:
  - Consumer Goods
release: "264"
---
# Create a Segmentation Rule Definition in Retail Execution

A rule definition is a Salesforce Object Query Language (SOQL) query defined as a string with variables specified in a specific syntax with bound attributes. To create a segmentation rule, create a segmentation rule definition. When creating a segmentation rule, enter a value for the variables defined in the rule definition.

### 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>Professional</strong>, <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="d81605e48">User Permissions Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e48 ">To create segmentation rule definition templates:</td>
            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e48 ">
              <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>

For example, write a query to select stores from certain states, where states is the variable. When you create a rule, you can enter Georgia as the parameter for the state variable. When the rule is run, a customer set is created with all the stores from the state of Georgia.

1. From the App Launcher, find and select **Segmentation Rule Definitions**, and then click **New**.
2. Provide these details:
    
    <table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
              <colgroup>
                <col style="width:50%">
                <col style="width:50%">
              </colgroup>
              <thead class="slds-text-title_caps ">
                <tr class="">
                  <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d81605e96">Field</th>
                  <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d81605e99">Description</th>
                </tr>
              </thead>
              <tbody>
                <tr class="">
                  <td class="slds-cell-wrap" colspan="2" style="vertical-align:top;" headers="d81605e96 d81605e99 ">Identification</td>

                </tr>
                <tr class="">
                  <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e96 ">Segmentation Rule Definition Name</td>

                  <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e99 ">Name of the segmentation rule definition.</td>

                </tr>
                <tr class="">
                  <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e96 ">State</td>

                  <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e99 ">
                    <p>Current state of the segmentation rule definition. The options are:</p>
                    <ul>
                      <li>Initial: The segmentation rule definition is created but isn't ready for use.</li>
                      <li>Released: The segmentation rule definition is ready for use.</li>
                    </ul>
                  </td>

                </tr>
                <tr class="">
                  <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e96 ">Use Account Hierarchy</td>

                  <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e99 ">
                    <p>Indicates whether account hierarchy is used.</p>
                    <div class="slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium">
                      <div class="slds-media slds-media_responsive">
                        <div class="slds-media__figure"><span class="slds-icon_container slds-icon_container_circle slds-icon-note-note"><img style="margin-bottom:0;" src="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_note.png" alt="Note"></span></div>
                        <div class="slds-media__body" style="padding-top:.5rem;padding-bottom:.5rem;"><span class="slds-text-title_caps">Note</span> You can either select this option
                          or the Use Org Unit Hierarchy option.</div>
                      </div>
                    </div>
                  </td>

                </tr>
                <tr class="">
                  <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e96 ">Use Org Unit Hierarchy</td>

                  <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e99 ">
                    <p>Indicates whether org unit hierarchy is used.</p>
                    <div class="slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium">
                      <div class="slds-media slds-media_responsive">
                        <div class="slds-media__figure"><span class="slds-icon_container slds-icon_container_circle slds-icon-note-note"><img style="margin-bottom:0;" src="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_note.png" alt="Note"></span></div>
                        <div class="slds-media__body" style="padding-top:.5rem;padding-bottom:.5rem;"><span class="slds-text-title_caps">Note</span> You can edit this field only if
                          a segmentation rule definition is in the Initial state.</div>
                      </div>
                    </div>
                  </td>

                </tr>
                <tr class="">
                  <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e96 ">Target</td>

                  <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e99 ">Target (SOQL) from which data is read.</td>

                </tr>
                <tr class="">
                  <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e96 ">Sales Org</td>

                  <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e99 ">Sales org of the segmentation rule definition. You can edit this field only during
                    creation.</td>

                </tr>
                <tr class="">
                  <td class="slds-cell-wrap" colspan="2" style="vertical-align:top;" headers="d81605e96 d81605e99 ">Description</td>

                </tr>
                <tr class="">
                  <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e96 ">Description</td>

                  <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e99 ">Description of the segmentation rule definition.</td>

                </tr>
                <tr class="">
                  <td class="slds-cell-wrap" colspan="2" style="vertical-align:top;" headers="d81605e96 d81605e99 ">SOQL</td>

                </tr>
                <tr class="">
                  <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e96 ">Segmentation Query</td>

                  <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d81605e99 ">
                    <p>SOQL statement with bindings for segmentation rule definition columns. </p>
                    <p>For each
                      placeholder in a query, the system validates whether an attribute is defined by parsing
                      the SOQL query and searching for placeholders of type $placeholder$. The system parses
                      the SOQL and determines the FROM part of the query. By SOQL standard, the FROM part is
                      always the source object, and the system validates whether the object is either Account
                      or Account_Extension__c.</p>
                    <p style="margin-bottom:0;">Always enter a WHERE clause in the query.</p>
                  </td>

                </tr>
              </tbody>
            </table>
3. Save your changes.
    
    After the configuration is completed, set the state of the rule definition to Released.
    
    ![Note](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_note.png)
    
    Note After you release a segmentation rule:
    
    - You can change the SOQL query of the rule definitions, but not its attributes.
    - You can’t add a segmentation rules definition column to a release segmentation rule.