The sub-workflow cannot access parameters from the root workflow directly. Instead parameters that are to be used in sub-workflows must be passed as input parameter of that sub-workflow. This is actually the same as passing parameters to inputs of tasks. A sub-workflow can be also regarded as being a (complex) workflow task.
However, the sub-workflow does not have an explicit contract defining its input parameters. Instead, the sub-workflow has a more implicit contract that is defined by the internal workflow parameters, as is the case with the root workflow.
This means one must create (sub-)workflow parameters in the same way as one does in root workflows. E.g. by adding a # variable to input parameters of task.
In our example, some workflow parameters are assigned to the "Add Item to Collection" task:
- Firstly, one assigns a workflow parameter called "SubWfCollectionId" to the "CollectionPlatformUri" input parameter:
- Next, a workflow parameter called "SubWfObjectId" is assigned to the "ItemPlatformUri" input parameter:
- Next, select the sub-workflow and check the "Input/Output" tab:
- The two sub-workflow parameters are now input parameters of the actual sub-workflow.
- One can now assign (as in previous example) the output "CollectionId" of the "global" "Create Collection" task to the corresponding input parameter of the sub-workflow. This implies that the same collection ID will be used in all iterations of that sub-workflow.
- As input for the "SubWfObjectId" parameter, the iterated element variable is used once again:
- This iterated Id of all assets in the collection will then be used by all tasks inside the workflow that need the corresponding item. In our example, "Add Item to Collection" will use it to add each item to the collection. "Update Metadata" will use it to update the corresponding metadata for each item.