Search code examples
azure-data-factoryoracle-adf

How to pass Variables return value in adf pipelines


In child pipeline1 I passed if condition in that true statement variable 1 is executed and in false statement variable2 is executed.

Now in ChildPipeline2 parameter I am passing value is @or(activity('childpipeline1'). output.pipelinereturnvalue.variable1,activity('childpipeline1'). output.pipelinereturnvalue.variable2,)

Now 2 cases when true statement executes and variable1 executes the expression is working.

When false statement executes and variable2 executes the expression is not working

Now 2 cases when true statement executes and variable1 executes the expression is working.

When false statement executes and variable2 executes the expression is not working.

I am getting an error like cannot evaluate because variable1 doesn't exist


Solution

  • enter image description here

    The above error occurs when the if expression inside the child pipeline results False. If its false, the variable2 value will be returned as true from child pipeline and pipeline don't know about the variable1 because it's not executed in this case.

    whereas if it's true, variable1 value will be returned as true and still pipeline don't know about variable2. But the reason for pipeline success in this case is @or() nature. If the first expression in the or() is true, then it won't check the second expression and it will give the total result as true.

    To achieve your requirement, follow the below steps.

    In child pipeline1 True activities of if, add both variable1 and variable2. If its true, give the values as true for variable1 and false for variable2.

    enter image description here

    Do the same in False activities of if, but give true for variable2 and false for the variable2.

    enter image description here

    Now, whatever might be the if expression result(True or False), both variables with proper values with be returned from the child pipeline1 and @or(activity('Execute Pipeline1').output.pipelineReturnValue.var1,activity('Execute Pipeline1').output.pipelineReturnValue.var2) will give correct value which you can pass to your next pipeline as per your requirement.

    enter image description here