
Hello:
I'm in the process of create Flow where is required process that runs in a cycle for each of the items. Example:
In the attach image I need to process the flow for each of the PGD Centers but at the same time for each center I need to assign all the Audit rules.
I was thinking use apply to each because at the time of read the data clearly Power Automate make a difference of each of the PGD Center Values in the Sharepoint Field. Example:
{
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 5,
"Value": "PGD Lebanon"
},
{
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 3,
"Value": "PGD Costa Rica"
},
{
"@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 1,
"Value": "PGD Argentina"
}
]
I even thought in add the values into one array but then had the problem that i don't have a clue on how to process the array. More than appreciated any help that you can provide.
Regards
crirojsab
Using a sample Array of Objects similar to yours (had to change it slightly for testing since using a dummy Compose), you can process like this:
1) use Apply to Each
2) Use an expression like this:
items('Apply_to_each')['Value']
Check if it helps.
Example:
Sample Flow Definition:
Sample Input, which is:
[
{
"something": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 5,
"Value": "PGD Lebanon"
},
{
"something": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 3,
"Value": "PGD Costa Rica"
},
{
"something": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 1,
"Value": "PGD Argentina"
}
]
the, entering into an Apply to Each:
"Outputs" under "Select an output from previous steps" in Apply to Each is the "Outputs" from "Compose" above (i.e. the test/dummy array) for which the Apply to Each is iterating over.
Compose 2 shows "Current item" - which I picked from Dynamic Content - this is here for illustration purposes. "Current item" here is actually equivalent to
items('Apply_to_each')
So, to process it, let's just access the value directly, like this:
items('Apply_to_each')['Value']
The expression
is here in Compose 3 in this example - and something like this is the one that you should use in your case to access the value directly.
Below, check a test Flow run to see the results:
Test Run Result (it works):
Notice "PGD Lebanon" as the output of Iteration #1 of the Apply to Each of the test run above. Only Iteration #1 is shown, but there are actually 3 iterations in this example. When checking the other Iterations, they show the correct expected values for those, too!
Check if something like this helps you.