Home > Mobile >  Can we use the parameters of FOREACH inside the activities of IF condition in azure data factory
Can we use the parameters of FOREACH inside the activities of IF condition in azure data factory

Time:11-17

How to use foreach activity parameters inside the if activity which is inside foreach i passed the values to the if condition like if true it will perform an activity but if false it had to use the values of the failed condition. but in the false condition i had to copy the false activity filenames to other location but in the filename option how to get parameters which are passed from the foreach activity

CodePudding user response:

Usually to get the current item in the iteration, you use item() in dynamic expression under ForEach iterator section in Add dynamic content tab

enter image description here

However, when you try to find it inside an activity i.e. past 2nd level of hierarchy

It is not listed!

enter image description here

Workaround:

Just inside of Foreach activity, use set variable activity to store the current item in iteration to a variable. Then reference this variable in further activities.

Example:

Simple ForEach activity with input array param

enter image description here

enter image description here

IfCondition activity inside ForEach activity. Assign current item to a variable var of type String

enter image description here

For case true it performs some activity eg: wait

enter image description here

For case false it performs a copy activity

Query: Select * from Persons where city = '@{variables('var')}'

enter image description here

enter image description here

  • Related