您位於此處:
InsProductJSONService:updateUserValues
使用此服務可根據使用者所做的變更,更新產品 JSON 中指定屬性的 userValues。您也可以使用此服務來更新 JSON 節點在階層中的位置。
方法:updateUserValues
運作方式
-
使用
inputKey和attributeValues在輸入 JSON 中尋找要更新的屬性節點。 -
如果已設定
productCode和/或attributeCode,則服務會篩選 JSON 以進行比對。 -
根據可能的屬性值驗證新屬性值 (若為
validate = true)。 -
使用更新的屬性傳回產品 JSON。
遠端選項
選項 |
描述 |
|---|---|
|
此服務用來尋找要使用的產品 JSON 部分的金鑰。 預設值為 |
|
尋找直接與此 |
|
尋找此 |
|
True/false 使用為 atttributeCode 指定的部分值來尋找屬性。 預設 = |
|
尋找與具有此 |
|
True/false 在更新 JSON 之前,根據指定屬性的所有允許值驗證新屬性值。 預設 = |
輸入 JSON
此服務會使用以 attributeCode 和新 userValues 對應形式的 inputKey 和 attributeValues 來取得其識別的一般產品 JSON。
若要瞭解如何建構產品 JSON,請參閱 產品 JSON 結構模型。
從以下範例中,liveCoverageAmt 的屬性值為 $250,000。且在「attributeValues」中,其將變更為 $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"
}
}
輸出 JSON
服務會傳回更新的產品 JSON,其中包含在 result 金鑰下方的新屬性值,以及原始屬性值的相關資訊。
在下列範例中,liveCoverageAmt 屬性的值已從 $250,000 變更為 $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
}
