Pipeline Expression Builder unable to reference ForEach item within If Condition

Kai Sor 70 Reputation points
2024-08-26T07:10:35.3066667+00:00

In ADF Pipeline, I have a For Each activity. Inside that For Each activity is an If Condition, and within that If Condition is a Copy Data activity.

In the Pipeline Expression Builder, I am able to select the For Each item within the If Condition source Dynamic Content.
User's image

However, for the Copy Data activity within that If Condition, I don't see the item in the builder UI. I have tried typing @item(), but that resulted in a syntax error during debug.
User's image

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,539 questions
0 comments No comments
{count} votes

Accepted answer
  1. AnnuKumari-MSFT 32,736 Reputation points Microsoft Employee
    2024-08-26T08:51:12.2233333+00:00

    Hi Kai Sor ,

    Thankyou for using Microsoft Q&A platform and thanks for posting your query here.

    As per my understanding you are trying to reference foreach activity item within Copy activity which is present inside the If block within Foreach activity.

    As mentioned in the error , you can't refer to the foreach activity output value as it is not direct ancestor to the copy activity. However, you can still make use of the expression using item function : @{item()} or @{item().tablename}to refer within copy activity.

    Simply, remove the expression @activity('Foreach1') and try @item() . It should work.

    Hope it helps. Kindly accept the answer by clicking on Accept answer button. Thankyou

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.