Running Maintenance and Digital Commerce Cache Jobs Remotely

You can run the Maintenance Jobs and the Digital Commerce API cache jobs programmatically by using anonymous Apex code as shown in the following examples.

Use this anonymous Apex job to build a streamlined version of the product hierarchies in the Data Store subjects. This is the same result as using Vlocity CMT Administration > Maintenance Jobs > Product Hierarchy Maintenance.

Use this anonymous Apex job to clear the org cache in the CPQPartition platform cache. This is the same result as using Vlocity CMT Administration > Maintenance Jobs > Clear Managed Platform Cache.

Use this anonymous Apex job to copy product hierarchy data to the platform cache and to rebuild the product attribute cache. This is the same result as using Vlocity CMT Administration > Maintenance Jobs > Refresh Platform Cache (Full).

Note that you must include the appropriate Pricebook2 ID in the script shown here:

Copy and paste the following Apex class into your org. This is a batch job that clears the cache. Use this if you have a large catalog or many context dimensions that result in a cache of 50k+ records.

You can fully clear the Digital Commerce API cache with the following anonymous Apex. Use it to debug and troubleshoot failures with the Digital Commerce APIs.

Use this anonymous Apex job to check a jobs' status. This is critical as the jobs can take a long time to run if you have a large catalog. Here is the anonymous apex for it:

This job populates the cache with the eligible offers for individual context combinations. The data is used by the GetOffers and GetContainOffers jobs.

You can run the job using anonymous apex code as shown here:

Use this job to generate, or populate, a full cache. This is the same result as using Vlocity CMT Administration > Cacheable API Jobs > Populate API Cache and selecting all of the jobs and catalogs.

This job populates the cache with the hierarchy of bundles. The data is used in the GetOfferDetails Job.

This job populates the cache with the list of offers for individual context combinations.

This job populates the cache with the parent offers for individual offers.

This job populates the cache with the prices of products. This is used in GetOffers, GetContainsOffers and GetOfferDetails jobs.

This job populates the cache with the details of individual offers (product or promotion).

You can run any of the batch jobs from anonymous Apex code by specifying the ID of the catalog. In the following example, the ID of the catalog is a0G0b00000dT45JEAS:

Run this job to regenerate cached API records. If the catalog has been modified, this job regenerates the cached API response objects based on the modified sales catalog and product models.