Loading
Prepare for Email to Become the Default Login ExperienceRead More
Get Started with Communications, Media, and Energy & Utilities (CME)...
Fix HierarchyResult Issues When Versioning is Enabled

Fix HierarchyResult Issues When Versioning is Enabled

When you create a product from the Product Console, you’re prompted to enter the effectivity dates of the product. For example - the effective date, selling start date, or selling end date. However, you aren't required to enter values for these fields in the Product Console. Due to this, you can create products with no effectivity dates.

In orgs with versioning enabled, this can cause issues when creating hierarchyResult entries in the CachedAPIResponse table of the database. This is because the Digital Commerce APIs expect at least the version start or version end dates to be populated. In such situations, you may see failures when running the GetOfferDetails and BasketOperations API calls on these products.

You can fix this issue by running a database script to populate the version start dates. The script populates the version start date for products that meet the following criteria:

  • Lifecycle status is set to Released.

  • Version start date is null.

  • Version end date is null.

Since the effective start dates and end dates are null, the script assumes that such products were always effective and sets the version start date to 01 Jan 1900.

  1. Click the setup icon, then click Developer Console.
  2. Click the Debug menu.
  3. Click Open Execute Anonymous Window.
  4. Enter this code snippet.
    // Must be less than or equal to 10000, which is the Salesforce governor limit
    Integer rowsLimit =9999;
    
    // this query fetches all such products whose LifeCycle status is "Released" but both Version Start and End dates set to NULL
    List<Product2> products = [select id from product2 where (vlocity_cmt__LifecycleStatus__c = 'Released') and (vlocity_cmt__VersionStartDateTime__c = null AND vlocity_cmt__VersionEndDateTime__c = null) LIMIT :rowsLimit];
    
    
    
    // the following loop iterates through each product and sets the Version Start Date to 01/01/1900
    for(Product2 product : products)
    {
        product.vlocity_cmt__VersionStartDateTime__c = Datetime.newInstance(1900, 01, 01, 0, 0, 0);
    }
    
    // updates all products in bulk
    update products;
    Note
    Note

    The rowsLimit integer must be less than or equal to 10000 to meet Salesforce governor limits. To update more than 10000 such products, run the script as many times as is required to update all products.

  5. Click Execute.
  6. Run maintenance jobs.
  7. Clear the CachedAPIResponse table entries and repopulate the table by running the Populate API Cache job.
 
Loading
Salesforce Help | Article