cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to use variable values in Parent Workflow in Child Workflow.

eric2
New Contributor

In ADF, a variable called Datetime was specified to be entered and executed in a workflow called Parent using Web Activity.

There is a Child Workflow (two-step workflow) in Parent Workflow, and Datetime variables are available in Parent Workflow, but Datetime variables are not available in Child Workflow.

In my opinion, I expected the variable to be inherited from Parent to Child, but it was not. How can I apply it to Child Workflow the same as Parent?

1 REPLY 1

Kaniz
Community Manager
Community Manager

Hi @eric2In Azure Data Factory (ADF), you must use pipeline parameters to pass variables from a parent pipeline to a child pipeline. You can define parameters in your child pipeline and then pass the variable values when you execute the child pipeline from the parent pipeline.

Here are the steps to do it:

1. Define parameters in your child pipeline:
   - In your child pipeline, go to the โ€™Parametersโ€™ tab and add a parameter. For example, you can name this parameter Datetime.

2. Pass the variable values from the parent pipeline:
   - In your parent pipeline, when you add the โ€™Execute Pipelineโ€™ activity to call the child pipeline, you can pass the variable's value to the child pipeline. In the โ€™Parametersโ€™ tab of the โ€™Execute Pipelineโ€™ activity, add the same parameter Datetime and set its value to the variable Datetime from the parent pipeline. Note: The parameters in the parent and child pipelines should have the same name to pass the values correctly.

Here is a sample code to pass the variable:

json
{
   "name": "Execute Child Pipeline",
   "type": "ExecutePipeline",
   "parameters": {
       "Datetime": "@variables('Datetime')"
   },
   "linkedServiceName": {
       "referenceName": "ChildPipeline",
       "type": "LinkedServiceReference"
   }
}

In this code, @variables('Datetime') is used to get the value of the Datetime Variable from the parent pipeline and pass it to the child pipeline. 

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.