---
schema_version: "1"
id: a2d8a14c782df1843a7116ba43a2e71fe471d3d124cb5a4a521406a55c41062f
title: EPC Product Attribute JSON
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/comms_epc_product_attribute_json.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.comms_epc_product_attribute_json.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 3dcdd1842acefd1d356d0272352d298ee1a34313219b50ce74542b779a124b43
description: This job regenerates the JSON Attribute fields for products managed through Vlocity Product Console. For products that are managed in Product Console, you can run this batch job in case the JSONAttribute gets out-of-sync with the attributes that are assigned to the product.
products:
  - Communications
  - Media
  - Energy and Utilities
release: "264"
---
# EPC Product Attribute JSON

This job regenerates the JSON Attribute fields for products managed through Vlocity Product Console. For products that are managed in Product Console, you can run this batch job in case the JSONAttribute gets out-of-sync with the attributes that are assigned to the product.

First get a list of Product2 Ids, `prodIds`, then call the batch job. Execute this code in the Exectue Anonymous window in the Developer Console.

```
Map<Id,Product2> products = new Map<Id,Product2>([SELECT Id FROM Product2]);
List<Id> productIds = new List<Id>(products.keySet());
Database.executeBatch(new vlocity_cmt.EPCProductAttribJSONBatchJob (productIds), 1);
```

<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="d41918e43">
              <p style="margin-bottom:0;">Applies to</p>
            </th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d41918e49">
              <p style="margin-bottom:0;">Summer '17 and later</p>
            </th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Applies to" class="slds-cell-wrap" style="vertical-align:top;" headers="d41918e43 ">
              <p style="margin-bottom:0;">Apex Name</p>
            </td>

            <td data-label="Summer '17 and later" class="slds-cell-wrap" style="vertical-align:top;" headers="d41918e49 ">
              <p style="margin-bottom:0;">
                <span class="apiname">EPCProductAttribJSONBatchJob</span>
              </p>
            </td>

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

            <td data-label="Summer '17 and later" class="slds-cell-wrap" style="vertical-align:top;" headers="d41918e49 ">
              <p style="margin-bottom:0;">Developer Console</p>
            </td>

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

            <td data-label="Summer '17 and later" class="slds-cell-wrap" style="vertical-align:top;" headers="d41918e49 ">
              <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="d41918e43 ">
              <p style="margin-bottom:0;">When Not to Run This Job</p>
            </td>

            <td data-label="Summer '17 and later" class="slds-cell-wrap" style="vertical-align:top;" headers="d41918e49 ">
              <p>Do not run this job In a live production
                environment when orders are being taken.</p>
              <p style="margin-bottom:0;">Do
                not run this job in orgs with products created using the Salesforce
                Classic interface instead of Vlocity Product Console.</p>
            </td>

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

            <td data-label="Summer '17 and later" class="slds-cell-wrap" style="vertical-align:top;" headers="d41918e49 ">
              <ul>
                <li>
                  <p>After spinning a new org.</p>
                </li>

                <li>
                  <p>After importing data containing product attributes.</p>
                </li>

                <li>
                  <p>Before running the Compile Data Job if you've made any attribute-related
                    changes or completed a datapack migration.</p>
                </li>

              </ul>
            </td>

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

            <td data-label="Summer '17 and later" class="slds-cell-wrap" style="vertical-align:top;" headers="d41918e49 ">
              <p>The
                <span class="apiname">EPCProductAttribJSONBatchJob</span> processes products
                attributes created with Vlocity Product Console and corrects the product
                attribute record IDs. It does not affect the org cache.
              </p>
              <p>It replaces the
                <span class="apiname">FixProductAttribJSONBatchJob</span> used prior to the
                ​Salesforce Industries Communications, Media, and
                Energy Summer ’17 release.
              </p>
              <p style="margin-bottom:0;">For
                more information, see <a href="https://help.salesforce.com/s/articleView?id=ind.comms_fix_product_attribute_json.htm&amp;release=264.0.0&amp;type=5" title="This job Regenerates the JSONAttribute fields for products managed through the Salesforce Classic interface, instead of Vlocity Product Console.">Fix Product Attribute
                  JSON</a>.</p>
            </td>

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

## Troubleshooting

If you update a picklist item, before you update the AttributeMetadata\_\_c or JSONAttribute\_\_c feilds, run this batch job to update the AttributeAssignment used by the EPCProductAttribJSONBatchJob.

```
global class UpdateAttributeAssignment implements Database.Batchable<sObject> 
             {
             String query;
             String attrId;
             String namespace = 'vlocity_cmt__';
             
             global UpdateAttributeAssignment(String attributeId) 
             {
             attrId = attributeId;
             }
             
             global Database.QueryLocator start(Database.BatchableContext BC) 
             {
             query = 'Select Id, ' +
             namespace + 'AttributeCategoryId__c ,' +
             namespace + 'AttributeId__c ,' +
             namespace + 'AttributeUniqueCode__c ,' +
             namespace + 'IsActive__c ,' +
             namespace + 'IsDynamic__c ,' +
             namespace + 'ObjectId__c ,' +
             namespace + 'ObjectLink__c ,' +
             namespace + 'ObjectType__c ,' +
             namespace + 'RemovedFlag__c ,' +
             namespace + 'ValueDescription__c ,' +
             namespace + 'AttributeCloneable__c ,' +
             namespace + 'AttributeConfigurable__c ,' +
             namespace + 'AttributeDisplayNameOverride__c ,' +
             namespace + 'AttributeDisplayName__c ,' +
             namespace + 'AttributeDisplaySequence__c ,' +
             namespace + 'AttributeFilterable__c ,' +
             namespace + 'AttributeName__c ,' +
             namespace + 'CategoryCode__c ,' +
             namespace + 'CategoryDisplaySequence__c ,' +
             namespace + 'CategoryName__c ,' +
             namespace + 'DisplaySequence__c ,' +
             namespace + 'HasRule__c ,' +
             namespace + 'IsActiveAssignment__c ,' +
             namespace + 'IsConfigurable__c ,' +
             namespace + 'IsHidden__c ,' +
             namespace + 'IsOverride__c ,' +
             namespace + 'IsQueryDriven__c ,' +
             namespace + 'IsReadOnly__c ,' +
             namespace + 'IsRequired__c ,' +
             namespace + 'PicklistId__c ,' +
             namespace + 'UIDisplayType__c ,' +
             namespace + 'ValidValuesData__c ,' +
             namespace + 'ValueDataType__c ,' +
             namespace + 'GlobalKey__c ,' +
             namespace + 'IsEncrypted__c ,' +
             namespace + 'IsNotAssetizable__c ,' +
             namespace + 'IsNotTranslatable__c ' +
             'From ' + namespace + 'AttributeAssignment__c Where ' + namespace +  'AttributeId__c = :attrId';
             return Database.getQueryLocator(query);
             }
             
             global void execute(Database.BatchableContext BC, List<sObject> scope) 
             {
             List<vlocity_cmt__AttributeAssignment__c> aaList = (List<vlocity_cmt__AttributeAssignment__c>) scope;
             List<Id> productIdList = new List<Id>();
             for (vlocity_cmt__AttributeAssignment__c aa: aaList)
             {
             Map<String, Object> inputs = new Map<String, Object>();
             inputs.put('so', aa);
             Object result =  vlocity_cmt.ProductConsoleControllerV2.invokeMethod('saveAttributeAssignment', JSON.serialize(inputs));
             }
             }	
             
             global void finish(Database.BatchableContext BC) 
             {
             }
             }
```

- In the Developer Console, create a new file and name it UpdateAttributeAssignment.cls.
- Copy and paste the code into this file.
- In the Developer Console's Anonymous Apex window, execute this code, replacing <attribute\_id> with the actual ID of the attribute associated with the picklist item you updated.
    
    ```
    Database.executeBatch(new UpdateAttributeAssignment ('<attributeId>'), 1);
    ```
- Regenerate AttributeMetadata by running EPCProductAttribJSONBatchJob.