Update Line Item Attributes
This API updates product attribute values for one or more cart line items.
| API | Signature |
|---|---|
| updateAttribute | webService static Boolean updateAttribute(Apttus_Config2.CPQStruct.UpdateProductAttributeValueDO request) |
Parameter
| Name | Type | Required? | Description |
|---|---|---|---|
| request | Apttus_Config2.CPQStruct.UpdateProductAttributeValueVal | Yes | Contains cart ID and list of attribute updates. |
Request Data Object – UpdateProductAttributeValueDO
| Field | Type | Description |
|---|---|---|
| ProductAttributeValues | List<Apttus_Config2.CPQStruct.ProductAttributeValueDO> | List of attribute value updates to apply to line items. |
| CartID | Id | The Cart Id on which the attributes are being updated. |
Request Data Object –
ProductAttributeValueDO
| Field | Type | Description |
|---|---|---|
| LineItemId | Id | Line Item ID whose attributes are to be updated. |
| AttributeValueSO | SObject | Base attribute SObject containing updated field values. |
| AttributeValueExtSO | SObject | Extension SObject 1 (if applicable). |
| AttributeValueExt2SO | SObject | Extension SObject 2 (if applicable). |
| AttributeValueExt3SO | SObject | Extension SObject 3 (if applicable). |
| NullFields | Map<String, List> | Map of SObject → list of fields to be nullified. |
Code Sample
The code below demonstrates how to update attribute values for a line item:
// Create the request object
Apttus_Config2.CPQStruct.UpdateProductAttributeValueDO request =
new Apttus_Config2.CPQStruct.UpdateProductAttributeValueDO();
request.CartID = 'a1lD3000004J1f6IAC'; // Cart Id
// List of attribute updates
List<Apttus_Config2.CPQStruct.ProductAttributeValueDO> attributeValues =
new List<Apttus_Config2.CPQStruct.ProductAttributeValueDO>();
// Attribute update entry
Apttus_Config2.CPQStruct.ProductAttributeValueDO attributeValueDO =
new Apttus_Config2.CPQStruct.ProductAttributeValueDO();
// Build the attribute SObject with updated values
String nsPrefix = 'Apttus_Config2__';
// String nsPrefix = RuntimeContext.getNSPrefix(); // optional dynamic prefix
SObject attributeValueSO = Schema.getGlobalDescribe()
.get(nsPrefix + 'ProductAttributeValue__c')
.newSObject();
// Set the attribute fields you want to update
attributeValueSO.put('Apttus_Config2__Color__c', 'Red'); // example update
// Assign SObject + target line item
attributeValueDO.AttributeValueSO = attributeValueSO;
attributeValueDO.LineItemId = 'a1VD3000003hkXDMAY';
// Add to request list
attributeValues.add(attributeValueDO);
request.ProductAttributeValues = attributeValues;
// Call the API
Boolean success = Apttus_CPQApi.CPQWebService.updateAttribute(request);
if (success) {
System.debug('Attributes updated successfully');
} else {
System.debug('Failed to update attributes');
}
