Call Workflow
Command Description
- You can create multiple workflows in the same automation application. Each workflow is compiled to a separate Python file.
- A called workflow can define input and output parameters.
- Splitting a large automation into subworkflows makes it easier to understand and maintain.
Command Input Parameters
| Input Parameter | Type | Description |
|---|---|---|
| Workflow Name | str | Name of the workflow to call. Use get_all_flow_names to retrieve the available workflow names |
Dynamic input parameter rules:
Workflow Nameis fixed and must identify the workflow to call.- Use
get_target_tab_flowto retrieve the selected workflow's other input parameters. - Each key in JSON
inmust exactly match an input parameter name in the target workflow. Each value must be a Python expression available in the current workflow.
Command Output Parameters
Dynamic output parameter rules:
- Use
get_target_tab_flowto retrieve the selected workflow's output parameters. - Each key in JSON
outmust exactly match an output parameter name in the target workflow. - Each value in JSON
outis a Python variable name, not a string literal. For example, write"ProductPrice": "ProductPrice", not"ProductPrice": "'ProductPrice'".
Example 1
Call Subworkflow B
Subworkflow B input parameters:
| Parameter Name | Type |
|---|---|
| webPage | WebPage |
| ProductName | str |
Subworkflow B output parameters:
| Parameter Name | Type |
|---|---|
| ProductPrice | str |
| ProductElement | WebElement |
The keys in out must exactly match Subworkflow B's output parameter names. The values are variable names and must not include Python string quotes.
[
{
"ins": "Open Webpage",
"in": {
"Browser Type": "'Google Chrome'",
"url": "'https://www.example.com'"
},
"out": {
"Webpage Object": "webPageObject"
}
},
{
"ins": "Call Workflow",
"in": {
"Workflow Name": "'Subworkflow B'",
"webPage": "webPageObject",
"ProductName": "'iPhone 15 Pro Max'"
},
"out": {
"ProductPrice": "ProductPrice",
"ProductElement": "ProductElement"
}
},
{
"ins": "Print Log",
"in": {
"Log Content": "f'''Product link: {ProductElement.href} Product price: {ProductPrice.replace('CNY ', '')}'''",
"Render HTML": "False"
}
}
]
Example 2
-
The subworkflow obtains the number of rows in the specified spreadsheet.
-
The current workflow waits until the subworkflow returns or finishes. In this example, the Example workflow executes line 4 before the Main workflow proceeds to line 2.
-
The calling workflow uses the returned result.