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.

PUT /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

putItemAttributes

Handlers

  • REST endpoint: APIItemAttributesItemsCartsCpqV2.cls

  • Implementation: CpqModifyAttributeActionV2.cls

Apex Remote Service

CpqAppHandler

Apex Remote Input Map

{
  "fields":null,
  "items":{JSONRECORD},
  "itemId":"8021I000001kvWeQAI",
  "cartId":"8011I000000TOcSQAW",
  "methodName":"putItemAttributes",
  "price":true,"validate":true
}

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/cpq/carts/{cart_ID}/items/{item_ID}/itemAttributes

Example Request

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

Example Request Body

{
  "methodName": "putItemAttributes",
  "items": {
    "records": [{
      "attributeCategories": {
        "totalSize": 1,
        "messages": [],
        "records": [{
          "messages": [],
          "displaySequence": 999,
          "Code__c": "0529CattegoryA",
          "Name": "0529CattegoryA",
          "id": "a0941000006fDUjAAM",
          "productAttributes": {
            "totalSize": 1,
            "messages": [],
            "records": [{
              "messages": [],
              "code": "A_PicklistAttribute_Text",
              "dataType": "text",
              "inputType": "dropdown",
              "multiselect": false,
              "required": false,
              "readonly": false,
              "disabled": false,
              "filterable": true,
              "attributeId": "a0A41000005Xp1IEAS",
              "label": "A_PicklistAttribute_Text",
              "displaySequence": 1,
              "hasRules": true,
              "values": [{
                  "id": "1",
                  "name": "1",
                  "label": "I am first (label)",
                  "readonly": false,
                  "disabled": false,
                  "value": "1",
                  "defaultSelected": false
                },
                {
                  "id": "2",
                  "name": "2",
                  "label": "I am second (label)",
                  "readonly": false,
                  "disabled": false,
                  "value": "2",
                  "defaultSelected": false
                },
                {
                  "id": "3",
                  "name": "3",
                  "label": "I am third (label)",
                  "readonly": false,
                  "disabled": false,
                  "value": "3",
                  "defaultSelected": false
                },
                {
                  "id": "4",
                  "name": "4",
                  "label": "I am no sequence (label)",
                  "readonly": false,
                  "disabled": false,
                  "value": "4",
                  "defaultSelected": false
                }
              ],
              "userValues": "1"
            }]
          }
        }]
      },
      "Id": {
        "value": "80241000006AutkAAC",
        "previousValue": null,
        "originalValue": null,
        "messages": [],
        "label": "Order Product ID",
        "hidden": false,
        "fieldName": "Id",
        "editable": false,
        "dataType": "ID",
        "actions": {}
      },
      "Product2": {
        "attributes": {
          "type": "Product2",
          "url": "/services/data/v41.0/sobjects/Product2/01t410000032V0sAAE"
        },
        "Name": "City2City",
        "vlocity_cmt__IsConfigurable__c": true,
        "vlocity_cmt__Type__c": "None",
        "vlocity_cmt__SubType__c": "None",
        "Id": "01t410000032V0sAAE",
        "vlocity_cmt__JSONAttribute__c": null
      },
      "PricebookEntry": {
        "attributes": {
          "type": "PricebookEntry",
          "url": "/services/data/v41.0/sobjects/PricebookEntry/01u41000004eEY1AAM"
        },
        "Product2Id": "01t410000032V0sAAE",
        "Pricebook2Id": "01s41000007liRQAAY",
        "Id": "01u41000004eEY1AAM",
        "Product2": {
          "attributes": {
            "type": "Product2",
            "url": "/services/data/v41.0/sobjects/Product2/01t410000032V0sAAE"
          },
          "Name": "City2City",
          "Id": "01t410000032V0sAAE",
          "ProductCode": "City2City",
          "vlocity_cmt__Type__c": "None",
          "vlocity_cmt__IsConfigurable__c": true
        },
        "value": {
          "attributes": {
            "type": "PricebookEntry",
            "url": "/services/data/v41.0/sobjects/PricebookEntry/01u41000004eEY1AAM"
          },
          "Product2Id": "01t410000032V0sAAE",
          "Id": "01u41000004eEY1AAM",
          "Product2": {
            "attributes": {
              "type": "Product2",
              "url": "/services/data/v41.0/sobjects/Product2/01t410000032V0sAAE"
            },
            "Name": "City2City",
            "Id": "01t410000032V0sAAE"
          }
        }
      },
      "PricebookEntryId": {
        "value": "01u41000004eEY1AAM",
        "previousValue": null,
        "originalValue": null,
        "messages": [],
        "label": "Price Book Entry ID",
        "hidden": false,
        "fieldName": "PricebookEntryId",
        "editable": false,
        "dataType": "REFERENCE",
        "actions": {}
      }
    }]
  },
  "filters": null,
  "itemId": "80241000006AutkAAC",
  "id": "80241000006AutkAAC",
  "cartId": "80141000002H2ILAA0",
  "price": true,
  "validate": true
}

Example Response

{
  "totalSize": 1,
  "messages": [{
    "severity": "INFO",
    "messageId": null,
    "message": "No attributes to be modified.",
    "code": "162",
    "bundleId": null,
    "actions": {}
  }],
  "records": [{
    "messages": [],
    "displaySequence": -1,
    "Id": {
      "value": "80241000006AutkAAC",
      "previousValue": null,
      "originalValue": null,
      "messages": [],
      "label": "Order Product ID",
      "hidden": false,
      "fieldName": "Id",
      "editable": false,
      "dataType": "ID",
      "actions": {}
    },
    "Product2": {
      "attributes": {
        "url": "/services/data/v41.0/sobjects/Product2/01t410000032V0sAAE",
        "type": "Product2"
      },
      "Name": "City2City",
      "vlocity_cmt__IsConfigurable__c": true,
      "vlocity_cmt__Type__c": "None",
      "vlocity_cmt__SubType__c": "None",
      "Id": "01t410000032V0sAAE",
      "vlocity_cmt__JSONAttribute__c": null
    },
    "PricebookEntry": {
      "attributes": {
        "url": "/services/data/v41.0/sobjects/PricebookEntry/01u41000004eEY1AAM",
        "type": "PricebookEntry"
      },
      "Product2Id": "01t410000032V0sAAE",
      "Pricebook2Id": "01s41000007liRQAAY",
      "Id": "01u41000004eEY1AAM",
      "Product2": {
        "vlocity_cmt__IsConfigurable__c": true,
        "vlocity_cmt__Type__c": "None",
        "ProductCode": "City2City",
        "Id": "01t410000032V0sAAE",
        "Name": "City2City",
        "attributes": {
          "url": "/services/data/v41.0/sobjects/Product2/01t410000032V0sAAE",
          "type": "Product2"
        }
      },
      "value": {
        "Product2": {
          "Id": "01t410000032V0sAAE",
          "Name": "City2City",
          "attributes": {
            "url": "/services/data/v41.0/sobjects/Product2/01t410000032V0sAAE",
            "type": "Product2"
          }
        },
        "Id": "01u41000004eEY1AAM",
        "Product2Id": "01t410000032V0sAAE",
        "attributes": {
          "url": "/services/data/v41.0/sobjects/PricebookEntry/01u41000004eEY1AAM",
          "type": "PricebookEntry"
        }
      }
    },
    "PricebookEntryId": {
      "value": "01u41000004eEY1AAM",
      "previousValue": null,
      "originalValue": null,
      "messages": [],
      "label": "Price Book Entry ID",
      "hidden": false,
      "fieldName": "PricebookEntryId",
      "editable": false,
      "dataType": "REFERENCE",
      "actions": {}
    },
    "attributeCategories": {
      "totalSize": 1,
      "messages": [],
      "records": [{
        "messages": [],
        "displaySequence": 999,
        "Code__c": "0529CattegoryA",
        "Name": "0529CattegoryA",
        "id": "a0941000006fDUjAAM",
        "productAttributes": {
          "totalSize": 1,
          "messages": [],
          "records": [{
            "messages": [],
            "code": "A_PicklistAttribute_Text",
            "dataType": "text",
            "inputType": "dropdown",
            "multiselect": false,
            "required": false,
            "readonly": false,
            "disabled": false,
            "filterable": true,
            "attributeId": "a0A41000005Xp1IEAS",
            "label": "A_PicklistAttribute_Text",
            "displaySequence": -1,
            "hasRules": true,
            "values": [{
                "id": "1",
                "name": "1",
                "label": "I am first (label)",
                "readonly": false,
                "disabled": false,
                "value": "1",
                "defaultSelected": false
              },
              {
                "id": "2",
                "name": "2",
                "label": "I am second (label)",
                "readonly": false,
                "disabled": false,
                "value": "2",
                "defaultSelected": false
              },
              {
                "id": "3",
                "name": "3",
                "label": "I am third (label)",
                "readonly": false,
                "disabled": false,
                "value": "3",
                "defaultSelected": false
              },
              {
                "id": "4",
                "name": "4",
                "label": "I am no sequence (label)",
                "readonly": false,
                "disabled": false,
                "value": "4",
                "defaultSelected": false
              }
            ],
            "userValues": "1"
          }]
        }
      }]
    }
  }]
}

note: 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.