Call Sub Workflow Step
Use the Call Sub Workflow step to start another workflow. You can call the sub workflow and either wait for it to complete, or call it and continue with your main workflow.
Use the Call Sub Workflow step for the following scenarios:
- When a workflow branch contains a complex series of tasks, or can leverage an existing workflow, calling a sub workflow makes design, debugging, and maintenance of the application more manageable
- Depending on settings, a sub workflow can allow two workflows to run in parallel
- Reuse existing workflow logic and build a series of workflows that represent optional functional capabilities that a "hub" workflow coordinates, which is often used in case management and similar scenarios
Drag the Call Sub Workflow step from the Basic category, or the Recent category onto the canvas.
Example of a Call Sub Workflow step in a workflow
- From the Toolbox click the Basic category and then drag the Call Sub Workflow step onto the canvas.
- Select the added step and click the expand / collapse toggle to expand the Configuration Panel. You can also double click the step to expand the panel.
- Select the Call Sub Workflow tab. Use this tab to configure the sub workflow details.
- Select the sub workflow from the drop down menu.
- Notice the Start Sub Workflow and Return Values sections populate.
- Check (or uncheck) Wait for the sub workflow to complete depending on your scenario.
- Use the Start Sub Workflow to supply the input mappings and select fields, item references, and the folio for the sub workflow.
In the added property field, type a value, use inline functions, or dynamic fields, by clicking on the Add button to expand the Context Browser. Within the Context Browser, select inline functions and fields from the Functions, Fields, SmartObjects and Workflow categories. Click and drag the function into the property field.
To add more properties, click the Add button.
- Use the Return Values to return values from the sub workflow after it completes. In this example, the sub workflow updates details on a SharePoint list (no return values are required in this scenario).
- Select the Deadline tab.
You can expire a step at a future date, or after an amount of time, to stop waiting for a sub workflow to complete. After the deadline, the main workflow moves to the next step.
- Click the calendar icon to display the date picker. Select a date.
- Drag and drop inline functions and field properties (from the Context Browser) into the field to create dynamic functions
- If this step starts on a weekday and is not completed within 30 minutes, the deadline is reached and step expires.
- If this step starts on a Saturday or Sunday it falls outside of the specified work hours. This means the workflow will wait till Monday 8 am (within working hours) and then expire the step.
- With the step selected, select the Properties tab.
- Click the Errors tab.
Your changes are automatically saved.
The following table explains the options available on this tab:
Option | Explanation | How to Use |
---|---|---|
Workflow | ||
Select Workflow | Contains a list of recently picked, opened, saved, and deployed workflows. You can browse and select deployed workflows. You need to have Admin rights to the workflow you want to add. For information on workflow rights, see Rights. Use the dynamic mode to create your own. Type values or create dynamic values by dragging Functions, Fields, SmartObjects and Workflow-related items from the Context Browser into the fields. | Select a workflow from the menu. Click the toggle button to switch between the menu and a dynamic field. |
Wait for sub workflow to complete | Allows you to specify if the main (parent) workflow waits for the sub (child) workflow to complete before continuing. By not selecting this option, the main workflow continues to the next step while the sub workflow runs. This is selected by default. | Check or uncheck the check box. |
Start Sub Workflow | Use input mappings to set fields, Item References, and the folio of the sub workflow from the main (parent) workflow. Type values or create dynamic values by dragging Functions, Fields, SmartObjects and Workflow-related items from the Context Browser into the fields. | Click the down arrow to open this section. Select fields and supply values. Click the Add button to add additional property fields. The add button is disabled if there are no properties that you can set. |
Return Values | Use this to return values from the sub workflow after it has completed. Setup mapping between the sub workflow's fields and the main workflow. Type values or create dynamic values by dragging Functions, Fields, SmartObjects and Workflow-related items from the Context Browser into the fields. For more information on how to use item references, see the Example of a sub workflow returning values to the main workflow using Item References section below | Click the down arrow to open this section. Select properties and supply return values. Click the Add button to add additional property fields. The add button is disabled if there are no properties that you can set. |
This is an example that allows you to store a task action result from the sub workflow in a data field of the main workflow.
The table below explains the options available on this tab:
Option | Explanation | How to Use |
---|---|---|
Deadline | ||
No Deadline | Use this to indicate if step deadline is added. This option is on by default. | Click No Deadline to wait indefinitely for the sub workflow to complete. |
On Date | Use this to indicate if step deadline is added for a specific date. | Click On Date to configure a deadline: |
After Time | Use this to indicate if a step deadline is added after the specified time. | Click After Time to wait for an amount of time before moving on. Enter values in the Days, Hours, Minutes or Seconds fields. Enter values individually or in a combination. |
Within Working Hours Only | This function only works when the After Time option is selected. It allows you to set the deadline to happen within specified working hours. If you select this option, the step expires after the set time within the specified working hours. If you don't select this option the deadline does not take these hours into consideration. To define the working hours for your business, click the working hours link. You need access to K2 Management to set the working hours. For more information on how to set your working hours see the Work Hours topic. The Default working hours drop down menu has a list of work hours defined in K2 Management. If you have not defined any working hours, the Default working hours option is selected. Example: You select the After Time options and specify that the step needs to expire after 30 minutes. You also select this to happen within working hours. The working hours option you select is for the Sales team, which means Monday to Friday 8 am - 5 pm. By default, the Within Working Hours Only option is checked. | Check the Within Working Hours Only box. Click the working hours link to edit or add the working hours parameters. Click the Default working hours drop down menu to select a pre-configured set of work hours. |
Expiration | ||
Expire active sub workflow if this step is expired | Use this to expire a sub workflow if the deadline or another expiration of the step occurs | Mark Expire active sub workflow if this step is expired to expire the sub workflow. |
The following table explains the options available on this tab:
Option | Explanation | How to Use |
---|---|---|
Title / Name | By default, each step on the canvas has a step title. You can change this title to suit your workflow logic and show it on the canvas by checking the Show Label box. | Enter a value into the Title field. |
Reset link | Use the link to reset any changes to the title. | Click the Reset link to reset the Title field to default value. |
Show Label | Allows you to see the step label on the canvas. The label shows the value of the title. | Check the check box to display step label on the canvas. |
Description | Allows you to add a detailed description for the step. | Enter a value into the Description field. |
Notes | Allows you to add additional notes for the step. | Enter a value into the Notes field. |
Different types of exceptions can occur on a step, such as:
Type | Description |
---|---|
Known exceptions | Any SmartWizard or standard wizard that has Boolean options for handling known exceptions have these options displayed as check boxes in the Known exceptions section of the Exceptions tab. |
Unhandled exceptions | Any unknown runtime exceptions. |
The tab contains the following unhandled exception:
Exception | Explanation | How to Use |
---|---|---|
Log Exception | Logs the exception to the error log. | Check the box to log the exception. |
The main workflow contains the following steps:
- The workflow starts with and moves on to an approval task
- The approved path sends an email
- The rejected path calls a sub workflow
- The main workflow ends when the sub workflow completes
The sub workflow contains the following steps:
- The child workflow contains a step that creates a list item in a SharePoint list
- The sub workflow is started when the rejected path is followed in the main workflow
- In this example, start the main workflow (Workshop 2017 Main Workflow) from K2 Management site. Click Start New.
- Add folio name and click Start to run the workflow.
- The workflow starts and is active.
- From the Workshop 2017 Main Workflow Process Details click, the Reports tab. To view the active instance, scroll down to the Activities section of the report.
Notice the main workflow is active.
- Open Workspace, and from the Denallix Administrator task list, select the Reject action.
- After rejecting the task, select the Workshop 2017 Main Workflow Details Reports tab. Scroll down to the Activities section. Make sure the Include System Activities check box is checked. The main workflow is no longer active and the sub workflow is started.
- Find the sub workflow in the Related Processes section and click the link.
- From the Process Overview report for the sub workflow, scroll down to the All Instances section. Notice that the sub workflow started and is completed successfully. This is also true for the main workflow because it ends after the sub workflow completes.
- From the SharePoint Workshop 2017 Contact Details list, the sub workflow executed successfully and updated the list item as expected.
For more information on reports, see the Reports topic.
For more information on adding SharePoint steps to your workflow canvas go to the Toolbox SharePoint topic.
The main workflow contains the following steps:
- The workflow starts and then calls the sub workflow
- A value within a data field is returned to the main workflow after the sub workflow completes
- This data field determines who receives the task. This is set up using the data field in a custom recipients rule
Sub workflow
The sub workflow contains the following steps:
- This workflow contains a Manager Approval step. The actions on this step are Approved and Rejected
- Depending on what action is selected, the data fields are set accordingly
- An Approved action sets the data field to True. This value is sent to the main workflow
- A Rejected action set the data field to False. This value is sent to the main workflow
- In this example, the main workflow stars and calls the sub workflow. The sub workflow handles the Manager Approval part of the workflow. The manager approves the leave request and the Approved data field sends a True value back to the main workflow, and the sub workflow ends.
- The Return Value section, within the main workflow, handles the mapping of the return value from the sub workflow. In this example, the value is passed through to the Child Approved Value field.
- The custom recipient rule makes sure that the Final Approval task (in the main workflow) is assigned to the correct recipient. This means that if the value passed through from the sub workflow is True, the task goes to the Human Resources department for approval. If the value form the child workflow is False, the task goes to Bob Maggio.
- Use the Edit Recipient Rule to create the rule.
- After the Final Approval tasks is actioned, the main workflow ends.
In this example, an employee submits a Leave Request form. This form contains information including name, number, leave start and end dates, and other information. The first step is a task approval.
If the employee has five or more available leave days, the approval task is sent to the HR department. However, if the employee has less then five available leave days, the approval task is sent to the head office. The task recipient receives a notification email. This contains the employee's leave request details as well as available leave days. The recipient selects either the Approved or Rejected action.
The employee receives an email notifying them of the decision of their leave request.
In this scenario, the sub workflow collects data on the available leave days. This data is sent back to the main workflow using an item reference, and is then used in the notification.
This is the sub workflow.
The sub workflow starts as soon as the main workflow reaches the Call Sub Workflow step. The sub workflow has a Start, SmartObject Method, and Set Data Fields steps, configured as follows:
- On the Start step, the Leave Request form is added via the wizard. Unlike the main workflow, the form does not start the sub workflow, but simply creates a reference.
- Add the form and select the I will do it myself later option when configuring the wizard. This creates the Main Leave Request reference.
- Select the Smart Object Method step, and then select the Child Leave Days SmartObject. This SmartObject contains the Employee Name, Employee Number, and the Available Leave Days information. From the Method menu, select the Get List option.
From the Identifier menu select the unique identifier. In this example, you selectID;Employee_Number.
- In the Filters section, select the Add Filter link. In this example, filter on the Employee Number. From the References section, in the Context Browser, drag Employee Number in to the filter.
- No Input Mappings are necessary for this SmartObject method. In the Output Mappings section, select the Create a Reference radio button and click Create. This creates the Child Leave Days reference.
- On the Set Data Field step, create a Child Available Leave Days variable. In the Update Workflow section, select this variable from the menu.
You use this variable to send the data to the main workflow, and it's filtered based on the employee number.
- From the References section, in the Context Browser, drag Available Leave Days property from the Child Leave Days reference in to the Update Workflow area.
- Deploy the child workflow.
For more information on configuring the SmartObject step, see the SmartObjects Overview topic.
For more information on configuring the Set Data Field step, see the Set Data Fields step topic.
For more information on deploying the workflow, see the Deploy a Workflow topic.
This is the main workflow.
The main workflow start when the employee completes the Leave Request form. The steps are configured as follows:
- Use the wizard to add a form to the Start step. Starting the workflow with a form creates a reference in the context browser.
- The Call Sub Workflow step starts the sub workflow. From the Workflow menu, select the child workflow. Make sure Wait for sub workflow to complete is checked. This ensures that the main workflow receives data from the sub workflow.
- In the Start Sub Workflow section, click the Add button. In the added line, select the Main Leave Request reference option. This is the reference created on the start step in the sub workflow.
- In the menu to the right, select the Main Leave Request reference. This is the reference created on the start step in the main workflow.
- In the Return Values section, specify the value returned from the sub (child) workflow. Click the Add button. From the Sub Workflow section drop down, select the Child Available Leave Days option. This is the item reference created in the sub workflow on Available Leave Days.
- From the This Workflow section drop menu, click Create New option to create the Main Available Leave variable. The Available Leave Days value returns to the main workflow.
- Select the Set Folio step. This step creates the folio for the workflow.
- In this example, the folio contains the value of the Main Available Leave Days variable to show the available leave days for the employee. Add a Day Difference function to calculate the total leave days requested using the Main Available Leave Days variable.
- Select the Leave Approval Step. This task step has two actions, Approved and Rejected.
- The task goes to Erica Ford or the HR Group.
- A recipients rule is configure to make sure the task routes to the correct recipient. The available leave days value, sent from the sub workflow, determines who gets the task. Use the Main Available Days variable in the rule as follows:
- If the employee's available leave days are five or less, the task goes to Erica
- If the employee's available leave days are six or more, the task goes to HR
- Customize the Task Notification to include the employee leave request details and the available leave days.
- In this example, the task completes and a message is sent to the employee. Add an Email step for both Approved and Rejected paths, and configure as shown below.
- Deploy the main workflow.
For more information on configuring the Set Folio step, see the Set Folio step topic.
For more information on configuring the Task tab, see the Task tab topic.
For more information on configuring the Recipients tab, see the Recipients tab topic.
Form more information on the Recipients Rule, see the Recipient Rule section within the Recipients tab topic.
For more information on how to customize the Notification Task message, see the Email Alert tab topic.
For more information on configuring the Send Email step, see the Send Email step topic.
For more information on deploying the workflow, see the Deploy a Workflow topic.
- The employee completes and submits the Leave Request form.
- The main workflow starts.
- The sub workflow starts and gets, using the employee number, the available leave days. Using the item references, the value is sent back to the main workflow.
- The sub workflow completes.
- The recipient rule evaluates the available leave days value received from the sub workflow. The employee has four days available, which means the task is sent to Erica Ford.
- Erica receives the notification.
- Erica opens the Workspace and approves the request.
- The final email is sent to the employee.
When working with the Call Sub Workflow step, keep in mind the following considerations:
- When you configure the step and select a deployed workflow, select recently picked workflows from the list or browse to the required workflow. You need to have Admin rights to the workflow you want to add. For information on workflow rights, see Rights.
- A Call Sub Workflow step cannot be added into a multi-step
- Use the same data field types between main and sub workflow, when using a dynamic workflow name
- There is no validation done on sub workflow configuration.