Access Custom Fields Using Cart Document
You can access custom fields defined on the Order or OrderItem objects by mapping them to keys in the cart document. These keys represent the internal identifiers for the custom fields and should exclude any namespace prefixes or __c suffixes. Once mapped, the custom field values can be retrieved or updated through the cart document wrapper during order or quote processing.
Custom Field Map configuration is only required to access custom fields on CpqCartDocumentItem, not on CpqCartDocument.
Add custom fields to the cart document using field mapping. After you create the custom field for Order or OrderItem sObjects, you can map them to a key in cart document. Since the key is the internal representation of the custom field in the cart document, it should not have a namespace or "__c". When value for a custom field will be updated using cart document wrapper, this mapping will be used to get the key in cart document and the corresponding node will be updated with the value. Similarly, this mapping will be used to create response (external representation, containing namespace prefix and "__c") from the internal cart document.
Example sample mapping record:

If a new custom field is created on OrderItem then a mapping record for the field should also be created. To create a new mapping.
- From Setup, in the Quick Find box, enter Custom Settings, and then select Custom Settings.
- Next to Custom Field Maps, click Manage.
- Click New and enter the details for your mapping record.
For new line items, if a custom field's value isn't set by a custom implementation, its default value is applied at the end of the postCartItems process, after validation and pricing.
When using Cart Document APIs in custom implementations such as pre-hooks and post-hooks or custom pricing steps, customers can access fields on both line items and the header object.
By default, only a predefined set of fields is loaded, and only those field values can be retrieved. To fetch or set a custom field added by the customer on line items using Cart Document APIs, the admin must create a field set on the corresponding object and include the custom field in that field set.
For example, if a custom field CartType__c is added to a header object like Order, and there is a requirement to read its value during cart operations in a custom implementation using Cart Document APIs, the customer must perform these steps.
-
Create a field set:
Create a new field set namedStandardAPIFieldson the Order object.
-
Add the custom field:
Add theCartType__cfield to theStandardAPIFieldsfield set. -
Clear cache and regenerate data:
Clear the managed platform cache, then run theGenerate EPC Compile Datajob from the Vlocity CMT Administration page. -
Once the setup is complete, the field value can be accessed in custom implementations as shown below.
Similarly, if a custom field LineItemType__c is added to the OrderItem object, the customer must perform these steps.
-
Create a field set: Create a new field set named
StandardAPIFieldson the Order Product object. -
Add the custom field: Add the
LineItemType__cfield to theStandardAPIFieldsfield set. -
Clear cache and regenerate data: Clear the managed platform cache, then run the
Generate EPC Compile Datajob from the Vlocity CMT Administration page. -
Once the setup is complete, the field value can be accessed in custom implementations as shown below.
- Custom fields are not populated on the CpqCartDocumentItem during the postCartsItems (AddToCart) scenario.
- Custom fields are not populated by default. However, if custom logic is implemented to set their values, the fields will be populated and accessible like in other APIs.