You are here:
InsProductJSONService:updateUserValues
Use this service to update the userValues of specified attributes in a product JSON, based on changes a user has made. You can also use this service to update where the JSON node is in the hierarchy.
Method: updateUserValues
How It Works
-
Uses the
inputKeyandattributeValuesto find the node in the input JSON with the attributes to be updated. -
If
productCodeand/orattributeCodeare set, the service filters the JSON to match. -
Validates the new attribute value against possible attribute values, if
validate = true. -
Returns the product JSON with the updated attributes.
Remote Options
Option |
Description |
|---|---|
|
The key this service uses to find the part of the product JSON to work with. The default value is |
|
Finds attributes directly associated with this |
|
Finds the attribute specified by this |
|
True/false Works with a partial value specified for atttributeCode to find an attribute. Default = |
|
Finds the attributes associated with the product (and the child products) that has this |
|
True/false Validates new attribute values against all allowed values for a given attribute before updating the JSON. Default = |
Input JSON
This service takes a typical product JSON it identifies using the inputKey and attributeValues in the form of a map of the attributeCode and the new userValues.
To learn how product JSONs are structured, see Product JSON Structure Model.
From the example below, the attributes value of liveCoverageAmt is $250,000. And in "attributeValues" it is to be changed to $500,000.
{
"inputKey": {
"totalSize": 1,
"records": [
{
"Name": "Product1",
"ProductCode": "Product1",
"attributeCategories": {
"totalSize": 1,
"records": [
{
"displaySequence": 449,
"id": "a0O6A000001XFIPUA4",
"Name": "Life Terms",
"Code__c": "LIFETERMS",
"productAttributes": {
"totalSize": 1,
"records": [
{
"code": "lifeCoverageAmt",
"dataType": "text",
"inputType": "dropdown",
"multiselect": false,
"required": false,
"readonly": false,
"disabled": false,
"filterable": true,
"attributeId": "a0P6A0000032HllUAE",
"label": "Coverage Amount",
"displaySequence": 1,
"hasRules": false,
"hidden": false,
"values": [
{
"id": "0",
"label": "$250,000",
"readonly": false,
"disabled": false,
"value": "250000"
},
{
"id": "1",
"label": "$500,000",
"readonly": false,
"disabled": false,
"value": "500000"
},
{
"id": "2",
"label": "$1,000,000",
"readonly": false,
"disabled": false,
"value": "1000000"
}
],
"userValues": "250000",
"parentProductId": "a2mf4000000kYR7AAM",
"parentProductCode": "InsLife",
"originalAttributeIndex": 0,
"originalCategoryIndex": 1,
"originalProductIndex": 1,
"pathFromChild": "attributeCategories.records[1].productAttributes.records[0]",
"pathFromRoot": "\"pathFromRoot\": \"childProducts.records[1].attributeCategories.records[1].productAttributes.records[0]\""
}
]
}
}
]
}
}
]
},
"attributeValues": {
"lifeCoverageAmt": "500000"
}
}
Output JSON
The service returns an updated product JSON with the new attribute values under the result key and information about the original attribute value.
In the following example, the value for the liveCoverageAmt attribute was changed from $250,000 to $500,000.
{
"records": [
{
"attributeCategories": {
"records": [
{
"productAttributes": {
"records": [
{
"pathFromRoot": "\"pathFromRoot\": \"childProducts.records[1].attributeCategories.records[1].productAttributes.records[0]\"",
"pathFromChild": "attributeCategories.records[1].productAttributes.records[0]",
"originalProductIndex": 1,
"originalCategoryIndex": 1,
"originalAttributeIndex": 0,
"parentProductCode": "InsLife",
"parentProductId": "a2mf4000000kYR7AAM",
"userValues": "500000",
"values": [
{
"value": "250000",
"disabled": false,
"readonly": false,
"label": "$250,000",
"id": "0"
},
{
"value": "500000",
"disabled": false,
"readonly": false,
"label": "$500,000",
"id": "1"
},
{
"value": "1000000",
"disabled": false,
"readonly": false,
"label": "$1,000,000",
"id": "2"
}
],
"hidden": false,
"hasRules": false,
"displaySequence": 1,
"label": "Coverage Amount",
"attributeId": "a0P6A0000032HllUAE",
"filterable": true,
"disabled": false,
"readonly": false,
"required": false,
"multiselect": false,
"inputType": "dropdown",
"dataType": "text",
"code": "lifeCoverageAmt"
}
],
"totalSize": 1
},
"Code__c": "LIFETERMS",
"Name": "Life Terms",
"id": "a0O6A000001XFIPUA4",
"displaySequence": 449
}
],
"totalSize": 1
},
"ProductCode": "Product1",
"Name": "Product1",
"displaySequence": -1
}
],
"totalSize": 1
}

