Get Assets for Account

Retrieve the assets for a specified account ID.

GET /v2/assets/{ID}/pricing?accountId={account_ID}

Remote Method

getAssetsByAccount

Handlers

REST Endpoint: APIAssetsContractsV2.cls
Implementation: CpqAssetsContractsActionV2.cls

Apex Remote Service

CpqAppHandler

Apex Remote Input Map

methodName: getAssetsByAccount
accountId: 0011I000007lzDO
includes: noContractAssets
effectiveAssetsDateFilter: 2019-04-05T07:00:00.000Z
pagesize: 2

Package

Communication (vlocity_cmt)

API Parameters and Response Format

For API parameter names and descriptions, see Cart-Based API Swagger Reference.

Resource Information

Response Format JSON
Resource URL /services/apexrest/{namespace}/v2/accounts/{account_ID}/assets

Example Request

GET /services/apexrest/vlocity_cmt/v2/accounts/0011I000007lzDO/assets?pagesize=2&includes=noContractAssets&effectiveAssetsDateFilter=2019-04-05T07:00:00.000Z

To populate the attributeCategories node in the response for getAsset API, provide one of the two fields Product2.AttributeMetadatac or JSONAttributec as an input.

If V2AttributeModel is enabled, then provide Product2.AttributeMetadatac. If V2AttributeModel is disabled, then pass JSONAttributec.

GET
/services/apexrest/vlocity_cmt/v2/accounts/{accountId}/assets?fields=vlocity_cmt**JSONAttribute**c

From Spring'25, the Get Assets for Account API applies the timeOffset in the effectiveAssetsDateFilte. If no offset is provided, it defaults to 00:00:00. To resolve this, append the time to the effectiveAssetsDateFilter parameter. Customers can set up a pre-hook to apply this adjustment automatically.

Pre-hook for getAssetsByAccount

The CPQ APIs allow you to write custom pre and post hooks for each API to implement custom logic. The pre-hook runs before the API executes, while the post-hook runs after the API executes.

  1. Write the custom class to implement the pre and post hook.

    Here's the sample code that appends the timeoffset to the effectiveAssetsDateFilter when only a date is provided.

global with sharing class CPQCustomHookImplementation implements vlocity_cmt.VlocityOpenInterface{
global Boolean invokeMethod(String methodName, Map<String, Object> input, Map<String, Object> output, Map<String, Object> options) {

    if( methodName.equalsIgnoreCase('getAssetsByAccount.PreInvoke')) {
         getAssetsByAccount_PreInvoke(methodName, input, output,options);
         return true;
    }

    return false;

}

private void getAssetsByAccount_PreInvoke(String methodName, Map<String, Object> input, Map<String, Object> output, Map<String, Object> options) {
   //This method gets called before getAssetsByAccount
   String dateStr = (String)input.get('effectiveAssetsDateFilter');
    if(dateStr.length() == 10){
         dateStr = dateStr+'T23:59:59.000Z';
         input.put('effectiveAssetsDateFilter',dateStr);
   }
}
}

  1. Create the interface implementation. For example: Interface Name = CpqAppHandlerHookInterface Implementation = CPQCustomHookImplementation

Example Response

{
 "totalSize": 1,
 "messages": [],
 "records": [{
  "messages": [],
  "actions": {
   "assetchangesite": {
    "rest": {
     "params": {},
     "method": "POST",
     "link": "/services/apexrest/vlocity_cmt/v2/carts?subaction=assetChangeSite"
    },
    "remote": {
     "params": {
      "assetList": ["02i1I00000058doQAA"],
      "moveDate": null,
      "toServiceLocation": null,
      "fromServiceLocation": null
     }
    },
    "client": {
     "params": {}
    }
   },
   "assettoquote": {
    "rest": {
     "params": {},
     "method": "POST",
     "link": "/services/apexrest/vlocity_cmt/v2/carts?subaction=assetToQuote"
    },
    "remote": {
     "params": {
      "assetList": ["02i1I00000058doQAA"],
      "requestDate": null
     }
    },
    "client": {
     "params": {}
    }
   },
   "assettoorder": {
    "rest": {
     "params": {},
     "method": "POST",
     "link": "/services/apexrest/vlocity_cmt/v2/carts?subaction=assetToOrder"
    },
    "remote": {
     "params": {
      "assetList": ["02i1I00000058doQAA"],
      "requestDate": null
     }
    },
    "client": {
     "params": {}
    }
   }
  },
  "displaySequence": -1,
  "Id": {
   "value": "02i1I00000058doQAA",
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "Asset ID",
   "hidden": true,
   "fieldName": "Id",
   "editable": false,
   "dataType": "ID",
   "actions": {}
  },
  "Quantity": {
   "value": 1.00,
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "Quantity",
   "hidden": true,
   "fieldName": "Quantity",
   "editable": false,
   "dataType": "DOUBLE",
   "actions": {}
  },
  "vlocity_cmt__ProvisioningStatus__c": {
   "value": "Active",
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "Provisioning Status",
   "hidden": true,
   "fieldName": "vlocity_cmt__ProvisioningStatus__c",
   "editable": false,
   "dataType": "STRING",
   "actions": {}
  },
  "vlocity_cmt__RecurringTotal__c": {
   "value": 10.00,
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "Recurring Total",
   "hidden": true,
   "fieldName": "vlocity_cmt__RecurringTotal__c",
   "editable": false,
   "dataType": "CURRENCY",
   "actions": {
    "pricedetail": {
     "rest": {
      "params": {},
      "method": "GET",
      link ": " / services / apexrest / vlocity_cmt / v2 / assets / 02 i1I00000058doQAA / pricing ? accountId = 0011 I000007ms8TQAQ & priceDetailsFields = vlocity_cmt__RecurringTotal__c & effectiveAssetsDateFilter = 2019 - 04 - 05 T07 : 00: 00.000 Z "

     },
     "remote": {
      "params": {
       "effectiveAssetsDateFilter": "2019-04-05T07:00:00.000Z",
       "priceDetailsFields": "vlocity_cmt__RecurringTotal__c",
       "priceDetail": true,
       "id": "02i1I00000058doQAA",
       "accountId": "0011I000007ms8TQAQ",
       "methodName": "getAssetPriceDetail"
      }
     },
     "client": {
      "records": [],
      "params": {}
     }
    }
   }
  },
  "vlocity_cmt__OneTimeTotal__c": {
   "value": 100.00,
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "One Time Total",
   "hidden": true,
   "fieldName": "vlocity_cmt__OneTimeTotal__c",
   "editable": false,
   "dataType": "CURRENCY",
   "actions": {
    "pricedetail": {
     "rest": {
      "params": {},
      "method": "GET",
      link ": " / services / apexrest / vlocity_cmt / v2 / assets / 02 i1I00000058doQAA / pricing ? accountId = 0011 I000007ms8TQAQ & priceDetailsFields = vlocity_cmt__RecurringTotal__c & effectiveAssetsDateFilter = 2019 - 04 - 05 T07 : 00: 00.000 Z "

     },
     "remote": {
      "params": {
       "effectiveAssetsDateFilter": "2019-04-05T07:00:00.000Z",
       "priceDetailsFields": "vlocity_cmt__OneTimeTotal__c",
       "priceDetail": true,
       "id": "02i1I00000058doQAA",
       "accountId": "0011I000007ms8TQAQ",
       "methodName": "getAssetPriceDetail"
      }
     },
     "client": {
      "records": [],
      "params": {}
     }
    }
   }
  },
  "vlocity_cmt__ContractId__c": {
   "value": "8001I0000000ThqQAE",
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "Contract",
   "hidden": false,
   "fieldName": "vlocity_cmt__ContractId__c",
   "editable": false,
   "dataType": "REFERENCE",
   "actions": {}
  },
  "vlocity_cmt__LineNumber__c": {
   "value": "0001",
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "Line Number",
   "hidden": true,
   "fieldName": "vlocity_cmt__LineNumber__c",
   "editable": false,
   "dataType": "STRING",
   "actions": {}
  },
  "vlocity_cmt__RootItemId__c": {
   "value": "02i1I00000058doQAA",
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "RootItemId",
   "hidden": true,
   "fieldName": "vlocity_cmt__RootItemId__c",
   "editable": false,
   "dataType": "STRING",
   "actions": {}
  },
  "vlocity_cmt__OneTimeCharge__c": {
   "value": 100.00,
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "One Time Charge",
   "hidden": true,
   "fieldName": "vlocity_cmt__OneTimeCharge__c",
   "editable": false,
   "dataType": "CURRENCY",
   "actions": {
    "pricedetail": {
     "rest": {
      "params": {},
      "method": "GET",
      link ": " / services / apexrest / vlocity_cmt / v2 / assets / 02 i1I00000058doQAA / pricing ? accountId = 0011 I000007ms8TQAQ & priceDetailsFields = vlocity_cmt__RecurringTotal__c & effectiveAssetsDateFilter = 2019 - 04 - 05 T07 : 00: 00.000 Z "

     },
     "remote": {
      "params": {
       "effectiveAssetsDateFilter": "2019-04-05T07:00:00.000Z",
       "priceDetailsFields": "vlocity_cmt__OneTimeCharge__c",
       "priceDetail": true,
       "id": "02i1I00000058doQAA",
       "accountId": "0011I000007ms8TQAQ",
       "methodName": "getAssetPriceDetail"
      }
     },
     "client": {
      "records": [],
      "params": {}
     }
    }
   }
  },
  "vlocity_cmt__OneTimeCalculatedPrice__c": {
   "value": 100.00,
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "One Time Calculated Price",
   "hidden": true,
   "fieldName": "vlocity_cmt__OneTimeCalculatedPrice__c",
   "editable": false,
   "dataType": "CURRENCY",
   "actions": {
    "pricedetail": {
     "rest": {
      "params": {},
      "method": "GET",
      link ": " / services / apexrest / vlocity_cmt / v2 / assets / 02 i1I00000058doQAA / pricing ? accountId = 0011 I000007ms8TQAQ & priceDetailsFields = vlocity_cmt__RecurringTotal__c & effectiveAssetsDateFilter = 2019 - 04 - 05 T07 : 00: 00.000 Z "

     },
     "remote": {
      "params": {
       "effectiveAssetsDateFilter": "2019-04-05T07:00:00.000Z",
       "priceDetailsFields": "vlocity_cmt__OneTimeCalculatedPrice__c",
       "priceDetail": true,
       "id": "02i1I00000058doQAA",
       "accountId": "0011I000007ms8TQAQ",
       "methodName": "getAssetPriceDetail"
      }
     },
     "client": {
      "records": [],
      "params": {}
     }
    }
   }
  },
  "vlocity_cmt__OneTimeManualDiscount__c": {
   "value": 0.00,
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "One Time Manual Discount",
   "hidden": true,
   "fieldName": "vlocity_cmt__OneTimeManualDiscount__c",
   "editable": false,
   "dataType": "PERCENT",
   "actions": {}
  },
  "vlocity_cmt__RecurringCharge__c": {
   "value": 10.00,
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "Recurring Charge",
   "hidden": true,
   "fieldName": "vlocity_cmt__RecurringCharge__c",
   "editable": false,
   "dataType": "CURRENCY",
   "actions": {
    "pricedetail": {
     "rest": {
      "params": {},
      "method": "GET",
      link ": " / services / apexrest / vlocity_cmt / v2 / assets / 02 i1I00000058doQAA / pricing ? accountId = 0011 I000007ms8TQAQ & priceDetailsFields = vlocity_cmt__RecurringTotal__c & effectiveAssetsDateFilter = 2019 - 04 - 05 T07 : 00: 00.000 Z "

     },
     "remote": {
      "params": {
       "effectiveAssetsDateFilter": "2019-04-05T07:00:00.000Z",
       "priceDetailsFields": "vlocity_cmt__RecurringCharge__c",
       "priceDetail": true,
       "id": "02i1I00000058doQAA",
       "accountId": "0011I000007ms8TQAQ",
       "methodName": "getAssetPriceDetail"
      }
     },
     "client": {
      "records": [],
      "params": {}
     }
    }
   }
  },
  "vlocity_cmt__RecurringCalculatedPrice__c": {
   "value": 10.00,
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "Recurring Calculated Price",
   "hidden": true,
   "fieldName": "vlocity_cmt__RecurringCalculatedPrice__c",
   "editable": false,
   "dataType": "CURRENCY",
   "actions": {
    "pricedetail": {
     "rest": {
      "params": {},
      "method": "GET",
      link ": " / services / apexrest / vlocity_cmt / v2 / assets / 02 i1I00000058doQAA / pricing ? accountId = 0011 I000007ms8TQAQ & priceDetailsFields = vlocity_cmt__RecurringTotal__c & effectiveAssetsDateFilter = 2019 - 04 - 05 T07 : 00: 00.000 Z "

     },
     "remote": {
      "params": {
       "effectiveAssetsDateFilter": "2019-04-05T07:00:00.000Z",
       "priceDetailsFields": "vlocity_cmt__RecurringCalculatedPrice__c",
       "priceDetail": true,
       "id": "02i1I00000058doQAA",
       "accountId": "0011I000007ms8TQAQ",
       "methodName": "getAssetPriceDetail"
      }
     },
     "client": {
      "records": [],
      "params": {}
     }
    }
   }
  },
  "vlocity_cmt__RecurringManualDiscount__c": {
   "value": 0.00,
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "Recurring Manual Discount",
   "hidden": true,
   "fieldName": "vlocity_cmt__RecurringManualDiscount__c",
   "editable": false,
   "dataType": "PERCENT",
   "actions": {}
  },
  "vlocity_cmt__ServiceAccountId__c": {
   "value": "0011I000007ms8TQAQ",
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "Service Account",
   "hidden": false,
   "fieldName": "vlocity_cmt__ServiceAccountId__c",
   "editable": false,
   "dataType": "REFERENCE",
   "actions": {}
  },
  "vlocity_cmt__BillingAccountId__c": {
   "value": "0011I000007ms8TQAQ",
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "Billing Account",
   "hidden": false,
   "fieldName": "vlocity_cmt__BillingAccountId__c",
   "editable": false,
   "dataType": "REFERENCE",
   "actions": {}
  },
  "vlocity_cmt__PricingLogData__c": {
   "value": "{\"LogData\":{\"OT_STD_PRC\":[{\"PriceListEntryId\":\"a2X1I0000009iFXUAY\",\"LogType\":\"PRICE\",\"PricingElementGlobalKey\":\"775e358f-31c4-e8de-e23d-e00bbbfedfa6\",\"StartValue\":100.00,\"SubType\":\"Standard\",\"Frequency\":null,\"ChargeTiming\":\"One-time\",\"EndValue\":100.00,\"DisplayText\":\"100$ OTSP\",\"PricingVariableCode\":\"OT_STD_PRC\",\"PricingElementId\":\"a2a1I000000Bar6QAC\",\"PromotionId\":null,\"OfferId\":null,\"PriceListId\":\"a2Y1I000000TlsrUAC\",\"BaseAdjustment\":null,\"BaseValue\":100.00,\"AdjustmentMethod\":null,\"AdjustmentValue\":0.00,\"Amount\":100.00,\"AdjustmentType\":\"None\",\"LogSequence\":0}],\"REC_MNTH_STD_PRC\":[{\"PriceListEntryId\":\"a2X1I0000009iFcUAI\",\"LogType\":\"PRICE\",\"PricingElementGlobalKey\":\"9ef41d53-1bba-017e-625a-b06ac2de2c28\",\"StartValue\":10.00,\"SubType\":\"Standard\",\"Frequency\":\"Monthly\",\"ChargeTiming\":\"Recurring\",\"EndValue\":10.00,\"DisplayText\":\"10$ RMSP\",\"PricingVariableCode\":\"REC_MNTH_STD_PRC\",\"PricingElementId\":\"a2a1I000000Bar1QAC\",\"PromotionId\":null,\"OfferId\":null,\"PriceListId\":\"a2Y1I000000TlsrUAC\",\"BaseAdjustment\":null,\"BaseValue\":10.00,\"AdjustmentMethod\":null,\"AdjustmentValue\":0.00,\"Amount\":10.00,\"AdjustmentType\":\"None\",\"LogSequence\":0}],\"OT_STD_PRC_CALC\":[{\"LogSequence\":0,\"DisplayText\":\"One Time Charge (100.00) - One Time Manual Discount (0.00%)\"}],\"OT_STD_PRC_TOTAL\":[{\"LogSequence\":0,\"DisplayText\":\"[One Time Calculated Price (100.00) + Rollup One Time Total (0.00)] x Quantity (1.00)\"}],\"REC_MNTH_STD_PRC_CALC\":[{\"LogSequence\":0,\"DisplayText\":\"Recurring Charge (10.00) - Recurring Manual Discount (0.00%)\"}],\"REC_MNTH_STD_PRC_TOTAL\":[{\"LogSequence\":0,\"DisplayText\":\"[Recurring Calculated Price (10.00) + Rollup Recurring Total (0.00)] x Quantity (1.00)\"}]},\"PricingVariableCodeFieldBinding\":{\"Quantity\":\"LINE_QUANTITY\",\"vlocity_cmt__EffectiveRecurringTotal__c\":\"EFF_REC_MNTH_STD_PRC_TOTAL\",\"vlocity_cmt__EffectiveOneTimeTotal__c\":\"EFF_OT_STD_PRC_TOTAL\",\"vlocity_cmt__OneTimeCalculatedPrice__c\":\"OT_STD_PRC_CALC\",\"vlocity_cmt__OneTimeManualDiscount__c\":\"OT_STD_PRC_DISC_PCT_MAN\",\"vlocity_cmt__OneTimeCharge__c\":\"OT_STD_PRC\",\"vlocity_cmt__RecurringTotal__c\":\"REC_MNTH_STD_PRC_TOTAL\",\"vlocity_cmt__RecurringCalculatedPrice__c\":\"REC_MNTH_STD_PRC_CALC\",\"vlocity_cmt__RecurringManualDiscount__c\":\"REC_MNTH_STD_PRC_DISC_PCT_MAN\",\"vlocity_cmt__RecurringCharge__c\":\"REC_MNTH_STD_PRC\",\"vlocity_cmt__OneTimeTotal__c\":\"OT_STD_PRC_TOTAL\",\"vlocity_cmt__EffectiveQuantity__c\":\"EFFECTIVE_QUANTITY\"},\"PriceAdjustmentPromoKeys\":[],\"PricingVariableCodeValues\":{\"LINE_QUANTITY\":1.00,\"OT_STD_PRC_DISC_PCT_MAN\":0.00,\"REC_MNTH_STD_PRC_DISC_PCT_MAN\":0.00,\"OT_STD_PRC\":100.00,\"OT_STD_PRC_CALC\":100.00,\"OT_STD_PRC_TOTAL\":100.00,\"REC_MNTH_STD_PRC\":10.00,\"REC_MNTH_STD_PRC_CALC\":10.00,\"REC_MNTH_STD_PRC_TOTAL\":10.00,\"ROLLUP_OT_STD_PRC_TOTAL\":0.00,\"ROLLUP_REC_MNTH_STD_PRC_TOTAL\":0.00,\"EFF_OT_STD_PRC_TOTAL\":100.00,\"EFF_REC_MNTH_STD_PRC_TOTAL\":10.00,\"EFFECTIVE_QUANTITY\":1.00},\"PricingVariableCodeBaseValues\":{\"OT_STD_PRC\":100.00,\"REC_MNTH_STD_PRC\":10.00},\"LogVersion\":\"1.0\",\"LastPricingTime\":\"2019-11-07T10:21:55.572Z\"}",
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "Pricing Log",
   "hidden": true,
   "fieldName": "vlocity_cmt__PricingLogData__c",
   "editable": false,
   "dataType": "TEXTAREA",
   "actions": {}
  },
  "vlocity_cmt__SequenceNumber__c": {
   "value": 1,
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "Sequence Number",
   "hidden": true,
   "fieldName": "vlocity_cmt__SequenceNumber__c",
   "editable": false,
   "dataType": "DOUBLE",
   "actions": {}
  },
  "vlocity_cmt__PricebookEntryId__c": {
   "value": "01u1I000000ZY4nQAG",
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "PricebookEntryId",
   "hidden": true,
   "fieldName": "vlocity_cmt__PricebookEntryId__c",
   "editable": false,
   "dataType": "STRING",
   "actions": {}
  },
  "vlocity_cmt__EffectiveQuantity__c": {
   "value": 1.00,
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "Effective Quantity",
   "hidden": true,
   "fieldName": "vlocity_cmt__EffectiveQuantity__c",
   "editable": false,
   "dataType": "DOUBLE",
   "actions": {}
  },
  "vlocity_cmt__EffectiveRecurringTotal__c": {
   "value": 10.00,
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "Effective Recurring Total",
   "hidden": true,
   "fieldName": "vlocity_cmt__EffectiveRecurringTotal__c",
   "editable": false,
   "dataType": "CURRENCY",
   "actions": {}
  },
  "vlocity_cmt__EffectiveOneTimeTotal__c": {
   "value": 100.00,
   "previousValue": null,
   "originalValue": null,
   "messages": [],
   "label": "Effective One Time Total",
   "hidden": true,
   "fieldName": "vlocity_cmt__EffectiveOneTimeTotal__c",
   "editable": false,
   "dataType": "CURRENCY",
   "actions": {}
  },
  "Name": "TestA",
  "promotions": {
   "totalSize": 0,
   "messages": []
  }
 }]
}