I am learning Logic App. Below is the logic app standard workflow I am working on:
I have 2 questions here.
Stored Proc action returns 900 rows in total, so the foreach loop iterates 900 times. For testing purposes, I need foreach to iterate only 50 or 100 records. Is there any way I can limit the foreach loop to iterate only 100 records?
I know I can achieve this through Stored Proc itself by modifying the select query but I am just curious to know if this can be achieved from workflow because we can limit Do-Until loop in workflow.
I want to compare val2 with valTest i.e., if valTest == val2 (something like below image)
But I am not able to get valTest and val2 values (for each iteration) inside if condition.
I tried below approaches:
To get val2 value inside if condition:
items('For_each')?['val2']
To get valTest value inside if condition:
outputs('Select_valTest')?['valTest']
But condition throws some error. How can I get val2 and valTest values inside if condition so that I can compare both?
Note that action (body) is using Liquid Template whose output is as below
[
{
"valTest": "54322"
},
{
"valTest": "13916"
},
{
"valTest": "13856"
},
{
"valTest": "13617"
},
{
"valTest": "00255"
},
{
"valTest": "00254"
},
{
"valTest": "14948"
},
{
"valTest": "14947"
}
]
Output of action (Result Result Sets) is as below:
[
[
{
"val1": null,
"val2": "00197"
},
{
"val1": null,
"val2": "00203"
},
{
"val1": null,
"val2": "00205"
},
{
"val1": "AAA",
"val2": "13946"
},
{
"val1": "ABB",
"val2": "13947"
},
{
"val1": "ZACD",
"val2": "13948"
},
{
"val1": "null",
"val2": "00255"
},
{
"val1": "TTTT",
"val2": "14947"
}
]
]
Output of action (body) is as below:
[
{
"val2": "00197"
},
{
"val2": "00203"
},
{
"val2": "00205"
},
{
"val2": "13946"
},
{
"val2": "13947"
},
{
"val2": "13948"
},
{
"val2": "00255"
},
{
"val2": "14947"
}
]
Update
After creating and running suggested workflow, I get below error:
Also, I think that the action "select(valTest)" (Liquid Template action) shall come inside for-each loop because I have to compare each val2 with each valTest.
As you see that the order of my output value for val2 and valTest is not same (though some values are same) Example: valTest: "00255" and val2: "00255". Upon comparison, every time the condition is FALSE. How can I tackle that?
Please also check your 'Append to array variable' action's value (items('For_each')['val2']). Do I need to replace val2 with something else when using single for each loop?