List Workflow Instances
Verb: listWorkflowInstances
Available from: <Standard>
Lists information regarding the Workflow instances created previously by the command Create Workflow Instance.
1. Workflow is a process flow control engine. A Workflow represents a process within a BPMN file.
2. Instance represents the item that should be processed. It is the variable responsible for receiving data for the Workflow execution, assigning each task to its respective process.
Syntax
listWorkflowInstances --workflow(Workflow) [--startdate(DateTime)] [--enddate(DateTime)] [--status(WorkflowInstanceStatuses)] --currenttask(String) [--batchkey(String)] [--businessstatus(String)] [--timeout(TimeSpan)] (List<WorkflowInstance>)=value
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--workflow | Workflow | Required | Workflow | Variable of type "Workflow" from which the list of instances will be obtained.
This variable is generated using the Workflow parameter of the Load Workflow command. |
--startdate | Start Date | Optional | Date Time | Starting date from which the instances will be listed. |
--enddate | End Date | Optional | Date Time | Ending date from which the instances will be listed. |
--status | Status | Optional | WorkflowInstanceStatuses | System status of the instances to be listed. Options:
|
--currenttask | Current Task | Only whenStatus is Suspended | Text | Name of the current task belonging to the Workflow variable defined in Workflow. |
--batchkey | Batch Key | Optional | Text | Unique identifier created in the Key parameter of the Create Batch command, used to assign the listed instance to a group.
There cannot be two identical identifiers within the current tenant. |
--businessstatus | Business Status | Optional | Text | Business Status used to identify instances according to the business rules logic.
This parameter is used for guidance within the flow, without interfering with the script's operation. |
--timeout | Timeout | Optional | Time Span, Number, Text | Maximum waiting time for the instance batch to be listed.
If no value is defined in the parameter of type timeout, the execution uses the context time defined by the Set Timeout command. If the script does not use this command, the default time is 5 seconds. |
Outputs
Script | Designer | AcceptedTypes | Description |
---|---|---|---|
value | Workflow Instance | List<Workflow Instance> | Returns the list of retrieved instances.
When the instances are returned, only the Instance ID attribute is filled out. To get all the data from an instance, use the Load Workflow Instance command and use the Instance ID previously obtained. |
Example
In the situation below, all the instances created in the script are listed, with the displayed quantity obtained.
defVar --name mappedWorkflow --type Workflow
defVar --name a --type Numeric --value 0
defVar --name workflow --type Workflow
defVar --name workflowInstance --type WorkflowInstance
defVar --name batchInstances --type WorkflowBatch
defVar --name instancesBatch --type List --innertype WorkflowInstance
defVar --name quantity --type Numeric
// Download the following file to run the command.
loadWorkflow --isfromfile --file "bpmnTestVar.bpmn" --process "Id_f12b1ed6-0ecd-4bf7-b245-9bf31b63e900" --automapvariables workflow=value
mapWorkflowActivities --workflow ${workflow} --mappings "Task_inc=beginSubroutine" mappedWorkflow=value
createBatch --description "Batch containing Workflow instances" --workflow ${workflow} --key initialBatch --comment "Creates a batch to store Workflow instances" batchInstances=value
goSub --label beginSubroutine
listWorkflowInstances --workflow ${workflow} --status "New" --batchkey initialBatch --timeout 00:00:30 instancesBatch=value
count --collection "${instancesBatch}" quantity=value
logMessage --message "\r\nBatch Name: ${batchInstances}\r\nNumber of Batch Instances:${quantity}" --type "Info"
beginSub --name beginSubroutine
while --left "${a}" --operator "Less_Than" --right 5
incrementVar --number ${a}
createWorkflowInstance --workflow ${workflow} --businessstatus "In Progress" --businessstatusreason "Developing Script" --defaultvalues "a=${a}" --batch ${batchInstances} workflowInstance=value
endWhile
endSub
Download File
To run the sample script, it is necessary to download the file and inform its path in the File parameter of the Load Workflow command.