This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice This article is not considered official documentation for K2 software and is provided "as is" with no warranties.
The goal of this KB is to provide a technique for building up a Workflow tasks' Serial Number.
Before You Begin
- Open an existing Workflow with a task.
- Create a new Workflow.
- Add a Task to the Workflow.
The serial number is built up using two identifiers for the Workflow and the task. In the database these are called the Activity Instance Destination ID and Process Instance ID.
In K2 5.1 and above, there are now "Workflow Properties" that were added to the context browser. We can use these to build up the Serial Number and then, we can use the Serial Number in SmartObjects Steps, Email Steps or other Steps within the workflow.
When a task is added to the workflow, additional workflow properties are added to the context browser. The properties will change depending on which step is selected in the workflow. For example, when the Task Step is selected there is a workflow property for the Task Serial Number; however, this property is only available when the Task Step is selected. It is available here because it is required for Smart Actions via the Task Notification Email.
If other steps are selected, the Task Serial Number property is not available. In these instances, we need to build up the Serial Number.
The Serial Number will look like this: [WorkflowID]_[TaskID]
WorkflowID = Process Instance ID
TaskID = Activity Instance Destination ID
In order to use the WorkflowID and TaskID as a Serial Number the Set Variables, SmartObject Method, and/or any other Workflow Steps needs to be grouped with the Task. Without the Workflow Steps being grouped with the Task, the workflow properties will not show and of the Task options. The screenshots below demonstrate what grouped Steps look like in the workflow.
Serial Number Mapping with Variable:
We can build the Serial Number by creating a "Serial Number" variable in the context browser and then passing these two ID properties into the variable. The steps below will outline this process:
1. Select the Task Step and open the Context Browser.
2. Add a Variable and call it "Serial Number". Make sure the Data Type is set to Text.
3. We need to set the variable first. We can do this by adding a Basic "Set Variables" Step to our Task Step in the workflow. Then we can populate the Serial Number variable by dragging our Workflow ID and Task ID from the Workflow Properties and separating them with an underscore ( _ ).
4. This Serial Number variable is now available to be used in other areas of the workflow.
Direct Serial Number mapping:
In addition to creating a Serial Number variable, we can also map the WorkflowID and TaskID directly to the SmartObject.