---
schema_version: "1"
id: 0734dc10c3d44e1c9858aa03a424c143251bb2c2c53765aebfd5385d98c61a25
title: Limit Assets Collected by the Digital Commerce API
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/industries/cme/guides/comms-t-limit-assets-collected-by-the-digital-commerce-api.md
canonical_url: https://developer.salesforce.com/docs/industries/cme/guide/comms-t-limit-assets-collected-by-the-digital-commerce-api.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: eccf0a8b871dc26a812f569d9a284c147e124501a854a947ecce406e8fe34497
products:
  - Communications, Media, Energy and Utilities APIs (Managed Package)
  - Industries Developer Documentation
---
# Limit Assets Collected by the Digital Commerce API

Communication, Media, and Energy cloud leverages the Salesforce asset object to indicate what products and services have been bought by the customer, according to the customer account. Other packages, code, or businesses processes, including those of a third party, can also leverage the Salesforce asset object and populate records in the object.

When too many asset records are created on the object outside of the CME-managed package, Digital Commerce reaches a governor limit and throws a SOQL error, such as `Too many query rows: 50001`, when trying to execute the Asset to Basket API.

To avoid reaching governor limits and getting the SOQL error, you can limit the assets collected by the Digital Commerce API.

1.  Create an Apex class named TransactionContextUtils.

    ```nolang
    public class TransactionContextUtils
    {
        private static vlocity_cmt.VOIInvoker invoker = vlocity_cmt.VOIInvoker.getInstance();
        private static vlocity_cmt.VlocityOpenInterface transactionContext = (vlocity_cmt.VlocityOpenInterface)invoker.invoke('DefaultTrxnCtxImplementation', 'debugCreate', null, null, null);


        public static Boolean put(String key, Object value)
        {
            return (Boolean)invokeMethod('put', key, null, value);
        }

        public static Object get(String key)
        {
            return invokeMethod('get', key, null, null);
        }

        public static void printTransactionContext()
        {
            Map<String, Object> input = new Map<String, Object>();
            Map<String, Object> output = new Map<String, Object>();
            Map<String, Object> options = new Map<String, Object>();
            transactionContext.invokeMethod('debug', input, output, options);
        }

        public static Object invokeMethod(String methodName, String key, Set<String> keys, Object value)
        {
            Map<String, Object> input = new Map<String, Object>();
            Map<String, Object> output = new Map<String, Object>();
            Map<String, Object> options = new Map<String, Object>();
            if (key != null)
            {
                input.put('key', key);
            }
            else if (keys != null)
            {
                input.put('keys', keys);
            }

            if (value != null)
            {
                input.put('value', value);
            }

            transactionContext.invokeMethod(methodName, input, output, options);

            return output.get('value');
        }
    }
    ```

2.  Create an Apex class named CustomAssetsContextParser.

    ```nolang
    global class CustomAssetsContextParser implements vlocity_cmt.VlocityOpenInterface
    {
        public static String NSP = 'vlocity_cmt';

        public Boolean invokeMethod(String methodName, Map<String, Object> input, Map<String, Object> output, Map<String, Object> options)
        {
            try
            {
                if (methodName.equalsIgnoreCase('parseContextInput'))
                {
                    return parseContextInput(input, output, options);
                }
                else
                {
                    return false;
                }
            }
            catch(Exception e)
            {
                //EcommLogger.error('AssetsContextParser', e);
                return false;
            }
        }

        private Boolean parseContextInput(Map<String, Object> input, Map<String, Object> output, Map<String, Object> options)
        {
            List<SObject> assets = new List<SObject>();
            TransactionContextUtils.put('AssetObjects', assets);

            Map<String, String> rootItemIdAssetKeyMap = new Map<String, String>();
            TransactionContextUtils.put('RootItemIdAssetKeyMap', rootItemIdAssetKeyMap);

            List<Object> contextVal = new List<Object>();
            output.put('ContextValue', contextVal);

            return true;
        }
    }
    ```

3.  Add and activate a new interface implementation for AssetsContextInterface named CustomAssetsContextParser.

    1.  From the App Launcher, click Interface Implemtations.

    2.  Click New.

    3.  In the **New Interface Implementation** dialog, for **Interface Name**, enter `AssetsContextInterface`.

    4.  Click Save.

    5.  Click the Related tab.

    6.  Beside **Interface Implementation Detail**, click New.

    7.  In the **New Interface Implementation Detail** dialog:

        - For **Available Implementation**, enter `CustomAssetsContextParser`.

        - For **Interface Name**, enter `CustomAssetsContextParser`.

        - Click the **Active** check box to activate the interface implementation.

    8.  Click Save.

        ![Assets Context Interface](https://developer.salesforce.com/docs/media/assetscontextinterface.png)
