Update Item Attributes

Update quantity, fields, and attributes for a specified line item in the cart.

To persist changes after calling this API, you must call the Update Items in Cart API.

1PUT /v2/cpq/carts/{cart_ID}/items/{item_ID}/itemAttributes

This API supports the guest user enhancements that Salesforce introduced with the Winter ‘21 release. To encrypt and decrypt data for guest users, use the UserSecurity class with this API. See Guest User Technical Details.

For additional information, ​see UserSecurity Class and CPQ and Digital Commerce Changes for Guest Users.

Remote Method 

1putItemAttributes

Handlers 

  • REST endpoint: APIItemAttributesItemsCartsCpqV2.cls

  • Implementation: CpqModifyAttributeActionV2.cls

Apex Remote Service 

1CpqAppHandler

Apex Remote Input Map 

1{
2  "fields":null,
3  "items":{JSONRECORD},
4  "itemId":"8021I000001kvWeQAI",
5  "cartId":"8011I000000TOcSQAW",
6  "methodName":"putItemAttributes",
7  "price":true,"validate":true
8}

Package 

Communication (vlocity_cmt)

API Parameters and Response Format 

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

Resource Information 

Response FormatJSON
Resource URL/services/apexrest/{namespace}/v2/cpq/carts/{cart_ID}/items/{item_ID}/itemAttributes

Example Request 

1PUT
2/services/apexrest/vlocity_cmt/v2/cpq/carts/80146000000iwCx/items/80236000009E2InAAK/itemAttributes

Example Request Body 

1{
2  "methodName": "putItemAttributes",
3  "items": {
4    "records": [{
5      "attributeCategories": {
6        "totalSize": 1,
7        "messages": [],
8        "records": [{
9          "messages": [],
10          "displaySequence": 999,
11          "Code__c": "0529CattegoryA",
12          "Name": "0529CattegoryA",
13          "id": "a0941000006fDUjAAM",
14          "productAttributes": {
15            "totalSize": 1,
16            "messages": [],
17            "records": [{
18              "messages": [],
19              "code": "A_PicklistAttribute_Text",
20              "dataType": "text",
21              "inputType": "dropdown",
22              "multiselect": false,
23              "required": false,
24              "readonly": false,
25              "disabled": false,
26              "filterable": true,
27              "attributeId": "a0A41000005Xp1IEAS",
28              "label": "A_PicklistAttribute_Text",
29              "displaySequence": 1,
30              "hasRules": true,
31              "values": [{
32                  "id": "1",
33                  "name": "1",
34                  "label": "I am first (label)",
35                  "readonly": false,
36                  "disabled": false,
37                  "value": "1",
38                  "defaultSelected": false
39                },
40                {
41                  "id": "2",
42                  "name": "2",
43                  "label": "I am second (label)",
44                  "readonly": false,
45                  "disabled": false,
46                  "value": "2",
47                  "defaultSelected": false
48                },
49                {
50                  "id": "3",
51                  "name": "3",
52                  "label": "I am third (label)",
53                  "readonly": false,
54                  "disabled": false,
55                  "value": "3",
56                  "defaultSelected": false
57                },
58                {
59                  "id": "4",
60                  "name": "4",
61                  "label": "I am no sequence (label)",
62                  "readonly": false,
63                  "disabled": false,
64                  "value": "4",
65                  "defaultSelected": false
66                }
67              ],
68              "userValues": "1"
69            }]
70          }
71        }]
72      },
73      "Id": {
74        "value": "80241000006AutkAAC",
75        "previousValue": null,
76        "originalValue": null,
77        "messages": [],
78        "label": "Order Product ID",
79        "hidden": false,
80        "fieldName": "Id",
81        "editable": false,
82        "dataType": "ID",
83        "actions": {}
84      },
85      "Product2": {
86        "attributes": {
87          "type": "Product2",
88          "url": "/services/data/v41.0/sobjects/Product2/01t410000032V0sAAE"
89        },
90        "Name": "City2City",
91        "vlocity_cmt__IsConfigurable__c": true,
92        "vlocity_cmt__Type__c": "None",
93        "vlocity_cmt__SubType__c": "None",
94        "Id": "01t410000032V0sAAE",
95        "vlocity_cmt__JSONAttribute__c": null
96      },
97      "PricebookEntry": {
98        "attributes": {
99          "type": "PricebookEntry",
100          "url": "/services/data/v41.0/sobjects/PricebookEntry/01u41000004eEY1AAM"
101        },
102        "Product2Id": "01t410000032V0sAAE",
103        "Pricebook2Id": "01s41000007liRQAAY",
104        "Id": "01u41000004eEY1AAM",
105        "Product2": {
106          "attributes": {
107            "type": "Product2",
108            "url": "/services/data/v41.0/sobjects/Product2/01t410000032V0sAAE"
109          },
110          "Name": "City2City",
111          "Id": "01t410000032V0sAAE",
112          "ProductCode": "City2City",
113          "vlocity_cmt__Type__c": "None",
114          "vlocity_cmt__IsConfigurable__c": true
115        },
116        "value": {
117          "attributes": {
118            "type": "PricebookEntry",
119            "url": "/services/data/v41.0/sobjects/PricebookEntry/01u41000004eEY1AAM"
120          },
121          "Product2Id": "01t410000032V0sAAE",
122          "Id": "01u41000004eEY1AAM",
123          "Product2": {
124            "attributes": {
125              "type": "Product2",
126              "url": "/services/data/v41.0/sobjects/Product2/01t410000032V0sAAE"
127            },
128            "Name": "City2City",
129            "Id": "01t410000032V0sAAE"
130          }
131        }
132      },
133      "PricebookEntryId": {
134        "value": "01u41000004eEY1AAM",
135        "previousValue": null,
136        "originalValue": null,
137        "messages": [],
138        "label": "Price Book Entry ID",
139        "hidden": false,
140        "fieldName": "PricebookEntryId",
141        "editable": false,
142        "dataType": "REFERENCE",
143        "actions": {}
144      }
145    }]
146  },
147  "filters": null,
148  "itemId": "80241000006AutkAAC",
149  "id": "80241000006AutkAAC",
150  "cartId": "80141000002H2ILAA0",
151  "price": true,
152  "validate": true
153}

Example Response 

1{
2  "totalSize": 1,
3  "messages": [{
4    "severity": "INFO",
5    "messageId": null,
6    "message": "No attributes to be modified.",
7    "code": "162",
8    "bundleId": null,
9    "actions": {}
10  }],
11  "records": [{
12    "messages": [],
13    "displaySequence": -1,
14    "Id": {
15      "value": "80241000006AutkAAC",
16      "previousValue": null,
17      "originalValue": null,
18      "messages": [],
19      "label": "Order Product ID",
20      "hidden": false,
21      "fieldName": "Id",
22      "editable": false,
23      "dataType": "ID",
24      "actions": {}
25    },
26    "Product2": {
27      "attributes": {
28        "url": "/services/data/v41.0/sobjects/Product2/01t410000032V0sAAE",
29        "type": "Product2"
30      },
31      "Name": "City2City",
32      "vlocity_cmt__IsConfigurable__c": true,
33      "vlocity_cmt__Type__c": "None",
34      "vlocity_cmt__SubType__c": "None",
35      "Id": "01t410000032V0sAAE",
36      "vlocity_cmt__JSONAttribute__c": null
37    },
38    "PricebookEntry": {
39      "attributes": {
40        "url": "/services/data/v41.0/sobjects/PricebookEntry/01u41000004eEY1AAM",
41        "type": "PricebookEntry"
42      },
43      "Product2Id": "01t410000032V0sAAE",
44      "Pricebook2Id": "01s41000007liRQAAY",
45      "Id": "01u41000004eEY1AAM",
46      "Product2": {
47        "vlocity_cmt__IsConfigurable__c": true,
48        "vlocity_cmt__Type__c": "None",
49        "ProductCode": "City2City",
50        "Id": "01t410000032V0sAAE",
51        "Name": "City2City",
52        "attributes": {
53          "url": "/services/data/v41.0/sobjects/Product2/01t410000032V0sAAE",
54          "type": "Product2"
55        }
56      },
57      "value": {
58        "Product2": {
59          "Id": "01t410000032V0sAAE",
60          "Name": "City2City",
61          "attributes": {
62            "url": "/services/data/v41.0/sobjects/Product2/01t410000032V0sAAE",
63            "type": "Product2"
64          }
65        },
66        "Id": "01u41000004eEY1AAM",
67        "Product2Id": "01t410000032V0sAAE",
68        "attributes": {
69          "url": "/services/data/v41.0/sobjects/PricebookEntry/01u41000004eEY1AAM",
70          "type": "PricebookEntry"
71        }
72      }
73    },
74    "PricebookEntryId": {
75      "value": "01u41000004eEY1AAM",
76      "previousValue": null,
77      "originalValue": null,
78      "messages": [],
79      "label": "Price Book Entry ID",
80      "hidden": false,
81      "fieldName": "PricebookEntryId",
82      "editable": false,
83      "dataType": "REFERENCE",
84      "actions": {}
85    },
86    "attributeCategories": {
87      "totalSize": 1,
88      "messages": [],
89      "records": [{
90        "messages": [],
91        "displaySequence": 999,
92        "Code__c": "0529CattegoryA",
93        "Name": "0529CattegoryA",
94        "id": "a0941000006fDUjAAM",
95        "productAttributes": {
96          "totalSize": 1,
97          "messages": [],
98          "records": [{
99            "messages": [],
100            "code": "A_PicklistAttribute_Text",
101            "dataType": "text",
102            "inputType": "dropdown",
103            "multiselect": false,
104            "required": false,
105            "readonly": false,
106            "disabled": false,
107            "filterable": true,
108            "attributeId": "a0A41000005Xp1IEAS",
109            "label": "A_PicklistAttribute_Text",
110            "displaySequence": -1,
111            "hasRules": true,
112            "values": [{
113                "id": "1",
114                "name": "1",
115                "label": "I am first (label)",
116                "readonly": false,
117                "disabled": false,
118                "value": "1",
119                "defaultSelected": false
120              },
121              {
122                "id": "2",
123                "name": "2",
124                "label": "I am second (label)",
125                "readonly": false,
126                "disabled": false,
127                "value": "2",
128                "defaultSelected": false
129              },
130              {
131                "id": "3",
132                "name": "3",
133                "label": "I am third (label)",
134                "readonly": false,
135                "disabled": false,
136                "value": "3",
137                "defaultSelected": false
138              },
139              {
140                "id": "4",
141                "name": "4",
142                "label": "I am no sequence (label)",
143                "readonly": false,
144                "disabled": false,
145                "value": "4",
146                "defaultSelected": false
147              }
148            ],
149            "userValues": "1"
150          }]
151        }
152      }]
153    }
154  }]
155}

When setting hasRules=true, it is expected that there is a rule configured. In case there are no Rules found, The putItemAttributes API will return “No attributes to be modified” response.

Note