What I would like to do it if there is addOn array, I would like to append the word "xxx" to the end of the name.
Schema applied to message.
{
"properties": {
"appointment": {
"properties": {
"id": {
"type": "integer"
},
"lines": {
"items": {
"properties": {
"addOn": {
"items": {
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "string"
}
},
"required": [
"id",
"name"
],
"type": "object"
},
"type": "array"
},
"id": {
"type": "integer"
},
"price": {
"type": "integer"
}
},
"required": [
"id",
"price"
],
"type": "object"
},
"type": "array"
}
},
"type": "object"
},
"messageId": {
"type": "string"
}
},
"type": "object"
}
Message 1
{
"messageId": "11",
"appointment": {
"id": 22,
"lines": [
{
"id": 33,
"price": 125.0,
"addOn": [
{
"id": 44,
"name": "test"
}
]
}
]
}
}
Message 2
{
"messageId": "11",
"appointment": {
"id": 22,
"lines": [
{
"id": 33,
"price": 125.0
}
]
}
}
Message 1 works fine but whenever I try and use length or Parse Array I get a message that addOn is null.
How can I put a proper Condition express to not get any errors or do nothing when there is no addOn array.
Message1 - Okay
Code View. { "definition": { "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", "actions": { "For_each": { "actions": { "For_each_2": { "actions": { "Condition_3": { "actions": {}, "expression": { "and": [ { "equals": [ "@empty(items('For_each_2'))", "True" ] } ] }, "runAfter": {}, "type": "If" } }, "foreach": "@items('For_each')['addOn']", "runAfter": {}, "type": "Foreach" } }, "foreach": "@body('Parse_JSON')?['appointment']?['lines']", "runAfter": { "Parse_JSON": [ "Succeeded" ] }, "type": "Foreach" }, "Parse_JSON": { "inputs": { "content": "@triggerBody()", "schema": { "properties": { "appointment": { "properties": { "id": { "type": "integer" }, "lines": { "items": { "properties": { "addOn": { "items": { "properties": { "id": { "type": "integer" }, "name": { "type": "string" } }, "required": [ "id", "name" ], "type": "object" }, "type": "array" }, "id": { "type": "integer" }, "price": { "type": "integer" } }, "required": [ "id", "price" ], "type": "object" }, "type": "array" } }, "type": "object" }, "messageId": { "type": "string" } }, "type": "object" } }, "runAfter": {}, "type": "ParseJson" } }, "contentVersion": "1.0.0.0", "outputs": {}, "parameters": {}, "triggers": { "manual": { "inputs": { "schema": { "properties": { "appointment": { "properties": { "id": { "type": "integer" }, "lines": { "items": { "properties": { "addOn": { "items": { "properties": { "id": { "type": "integer" }, "name": { "type": "string" } }, "required": [ "id", "name" ], "type": "object" }, "type": "array" }, "id": { "type": "integer" }, "price": { "type": "integer" } }, "required": [ "id", "price", "addOn" ], "type": "object" }, "type": "array" } }, "type": "object" }, "messageId": { "type": "string" } }, "type": "object" } }, "kind": "Http", "type": "Request" } } }, "parameters": {} }
Steve