How can I manage to add, update or delete a property of an object in a variable in Azure Logic Apps?
Example of my object before:
{
"prop1": "value1"
}
Example of my object after:
{
"prop1": "value1",
"prop2": "value2",
}
I would like to use the Set variable
operation in order to add a new property in the variable (I used the union
function, but with a temporary variable because assigning a self-referenced value to a variable isn't authorized).
Thank you for your help!
You can use an Initialize variable to create the prop2 variable or you can source it from wherever you need to. Then you can use Compose step to combine the prop1 and prop2. To illustrate, I used a http triggered logic app with a JSON body of "prop1" and value "value1". I think Initialize the variable "prop2" to "value2". For my compose block I used the input
{
"prop1": "@{triggerBody()?['prop1']}",
"prop2": "@{variables('prop2')}"
}
My output is a webhook which will receive the combined JSON as
{
"prop1": "value1",
"prop2": "value2"
}