---
schema_version: "1"
id: 3f3e50dac0df7be0bce655e37fe7004c5137e3b871654a3da168a62a94bbee07
title: Account Hierarchy Maintenance
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/comms_account_hierarchy_maintenance.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.comms_account_hierarchy_maintenance.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 1c10bbd297b1d0bf9c4cbc2b6cad512aec1faa1aa3f61425f3a815c58d63c360
description: This maintenance job adds any missing root account fields for hierarchical accounts.
products:
  - Communications
  - Media
  - Energy and Utilities
release: "264"
---
# Account Hierarchy Maintenance

This maintenance job adds any missing root account fields for hierarchical accounts.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col>
          <col>
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d345022e34">
              <p style="margin-bottom:0;">Applies to</p>
            </th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d345022e40">
              <p style="margin-bottom:0;">All releases</p>
            </th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Applies to" class="slds-cell-wrap" style="vertical-align:top;" headers="d345022e34 ">
              <p style="margin-bottom:0;">Apex Name</p>
            </td>

            <td data-label="All releases" class="slds-cell-wrap" style="vertical-align:top;" headers="d345022e40 ">
              <p style="margin-bottom:0;">
                <span class="apiname">ResolveRootAccountBatchJob</span>
              </p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Applies to" class="slds-cell-wrap" style="vertical-align:top;" headers="d345022e34 ">
              <p style="margin-bottom:0;">Where to Run This Job</p>
            </td>

            <td data-label="All releases" class="slds-cell-wrap" style="vertical-align:top;" headers="d345022e40 ">
              <p style="margin-bottom:0;">CMT Administration tab</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Applies to" class="slds-cell-wrap" style="vertical-align:top;" headers="d345022e34 ">
              <p style="margin-bottom:0;">Risks of Running This
                Job</p>
            </td>

            <td data-label="All releases" class="slds-cell-wrap" style="vertical-align:top;" headers="d345022e40 ">
              <p style="margin-bottom:0;">None</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Applies to" class="slds-cell-wrap" style="vertical-align:top;" headers="d345022e34 ">
              <p style="margin-bottom:0;">When Not to Run This
                Job</p>
            </td>

            <td data-label="All releases" class="slds-cell-wrap" style="vertical-align:top;" headers="d345022e40 ">
              <p style="margin-bottom:0;">N/A</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Applies to" class="slds-cell-wrap" style="vertical-align:top;" headers="d345022e34 ">
              <p style="margin-bottom:0;">When to Run This Job</p>
            </td>

            <td data-label="All releases" class="slds-cell-wrap" style="vertical-align:top;" headers="d345022e40 ">
              <ul>
                <li>
                  <p>After migrating hierarchical account data to ensure that the
                    migrated data has valid root account IDs.</p>
                </li>

                <li>
                  <p>Anytime that you find any root account IDs are missing.</p>
                </li>

              </ul>
            </td>

          </tr>
          <tr class="">
            <td data-label="Applies to" class="slds-cell-wrap" style="vertical-align:top;" headers="d345022e34 ">
              <p style="margin-bottom:0;">More Information</p>
            </td>

            <td data-label="All releases" class="slds-cell-wrap" style="vertical-align:top;" headers="d345022e40 ">
              <p>The Account Hierarchy Maintenance job resolves the root account
                field for all accounts in the org. It is especially useful if your org has
                complex account hierarchies and relationships, because during data
                migration, it is likely that IDs must be resolved in the target
                org.</p>
              <p>The <strong class="uicontrol">Root Account</strong>
                (<strong class="uicontrol">vlocity_cmt__RootAccountId__c</strong>) field stores the
                root account ID for each account in the hierarchy. The <strong class="uicontrol">Root
                  Account</strong> field is essential to maintain relationships between
                accounts. The Account Hierarchy Maintenance job finds any accounts that
                have a null root account field and then adds the root account ID. The job
                reports any errors encountered in the job status email it sends to the org
                administrator.</p>
              <p>After running the Account Hierarchy Maintenance
                job,&nbsp;you can run the below query to validate the data in your org:</p>
              <ol>
                <li>
                  <p>Open the Developer Console.</p>
                </li>

                <li>
                  <p>In the Query Editor tab, paste the following SOQL:</p>
                  <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>SELECT COUNT() FROM Account WHERE vlocity_cmt__IsRootResolved__c = false AND ParentId != null;</code></pre>
                </li>

                <li>
                  <p>Click <strong class="uicontrol">Execute</strong>.</p>
                  <p>If the query returns 0 rows, there are no accounts that need to be
                    updated.</p>
                </li>

              </ol>
            </td>

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

You can run this query to validate that the Account Maintenance Hierarchy job completed successfully:

`SELECT COUNT() FROM Account WHERE vlocity_cmt__IsRootResolved__c = false AND ParentId != null;`

The query should return zero rows.