'How can i run a propery in logic app for each only first run of the loop?
Solution 1:[1]
To remove properties from an object you can use
removeProperty function https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#removeProperty
But not sure how this is possible in your loop. If you always want to remove it after the first run, why not do the first "run" outside the loop, then loop the rest?
Solution 2:[2]
One of the workaround is to add the property outside the foreach loop in order to have it only once. For instance here is the sample json I have taken
{
"shipmentLines":
[
{
"PART_NO":1,
"WEB_ORDER_LINE_NUMBER":20,
"WEB_ORDER_NUMBER":30
},
{
"PART_NO":2,
"WEB_ORDER_LINE_NUMBER":298,
"WEB_ORDER_NUMBER":347
}
]
}
This is my Logic app where I'm storing the Compose content to an array variable and removing the pickedQuantity property and added after the foreach loop:-

Here is the Json code in my Compose 2 Connector.
{
"shipmentLines": [
{
"pickedQuantity": "1",
"shipmentDetails": @{variables('SampleArray')}
}
]
}
Here is the output:-

The Final Compose output:-
{
"shipmentLines": [
{
"pickedQuantity": "1",
"shipmentDetails": [
{
"shipmentLines": [
{
"articleNo": "2",
"customerOderNo": "347",
"lineNumber": "298"
}
]
},
{
"shipmentLines": [
{
"articleNo": "1",
"customerOderNo": "30",
"lineNumber": "20"
}
]
}
]
}
]
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | viktorh |
| Solution 2 | SwethaKandikonda-MT |

