InterSystems IRIS Data Platform 2020.4 > Class Reference > ENSLIB namespace > EnsLib.Workflow.Engine

EnsLib.Workflow.Engine

class EnsLib.Workflow.Engine extends %Library.RegisteredObject

Provides the core APIs for the Ensemble Workflow system.

Method Inventory (Including Private)

Methods (Including Private)

classmethod %CancelRequest(pRequest As TaskRequest) as %Status [ Language = objectscript ]
Cancel a workflow task. Called when original request times out.
classmethod %CreateObject(pClass As %String) as %RegisteredObject [ Language = objectscript ]
Helper method to create an object instance given a class name.
classmethod %DistributeTask(pRoleName As %String, pRequest As TaskRequest, pToken As %String) as %Status [ Language = objectscript ]
Takes a Task and distributes it, via a Task object, to a role. Called by Workflow operation when a new task arrives.
classmethod %OnRoleChange(pRoleName As %String, pReason As %String) as %Status [ Language = objectscript ]
Notification that a Role definition has been changed.
Possible values for pReason are:
  • $$$WfRoleDeleted--The role has been deleted.
classmethod %OnRoleMembershipChange(pRoleName As %String, pReason As %String, pUserName As %String) as %Status [ Language = objectscript ]
Notification that the Role membership has been changed.
Possible values for pReason are:
  • $$$WfUserAddedToRole--A user has been added to the role.
  • $$$WfUserRemovedFromRole--A user has been removed from the role.
classmethod %OnUserChange(pUserName As %String, pReason As %String) as %Status [ Language = objectscript ]
Notification that a User definition has been changed.
Possible values for pReason are:
  • $$$WfUserDeleted--The user has been deleted.
  • $$$WfUserInactivated--The user has been inactivated.
  • $$$WfUserActivated--The previously inactive user has been activated.
classmethod %ProcessAction(pActionId As %String, pItemId As %String, pUserName As %String, ByRef pMsg As %String) as %Status [ Language = objectscript ]
A request to process an action for a task. Called by Workflow Form when User makes an Action.
classmethod %RelinquishOwnershipForTask(pItemId As %String, pUser As %String, ByRef pMsg As %String) as %Status [ Language = objectscript ]
A request to unassign an assigned task. Called by Workflow Form when User requests task relinquishment.
classmethod %TakeOwnershipForTask(pItemId As %String, pUser As %String, ByRef pMsg As %String) as %Status [ Language = objectscript ]
A request to assign a task to specific user Called by Workflow Form when User requests onwership.
classmethod AssignTask(pTask As EnsLib.Workflow.TaskResponse, pUser As %String, Output pCount As %Integer) as %Status [ Language = objectscript ]
This Workflow API method assigns a Task to a specific User.
classmethod BamActiveLoad(pRole As %String) as %Integer [ Language = objectscript ]
Calculate the Active Load for a given role.
Active Load is the number of active tasks expressed as a percentage of the given role's capacity setting:
ActiveLoad = (ActiveTasks / Role.Capacity) * 100
classmethod BamActiveTasks(pRole As %String) as %Integer [ Language = objectscript ]
Calculate the number of Active Tasks for a given role.
Active Tasks is the number of tasks that are not marked as complete.
classmethod BamAvgTaskTime(pRole As %String, pStart As %TimeStamp = "", pEnd As %TimeStamp = "") as %Integer [ Language = objectscript ]
Calculate the average duration (in seconds) of Completed Tasks for a given role created within the given time window.
pStart and pEnd are in in %TimeStamp format: yyyy-mm-dd
classmethod BamCompletedTasks(pRole As %String, pStart As %TimeStamp = "", pEnd As %TimeStamp = "") as %Integer [ Language = objectscript ]
Calculate the number of Completed Tasks for a given role created within the given time window.
pStart and pEnd are in in %TimeStamp format: yyyy-mm-dd
classmethod BamMaxTaskTime(pRole As %String, pStart As %TimeStamp = "", pEnd As %TimeStamp = "") as %Integer [ Language = objectscript ]
Calculate the maximum duration (in seconds) of Completed Tasks for a given role created within the given time window.
pStart and pEnd are in in %TimeStamp format: yyyy-mm-dd
classmethod BamMinTaskTime(pRole As %String, pStart As %TimeStamp = "", pEnd As %TimeStamp = "") as %Integer [ Language = objectscript ]
Calculate the minimum duration (in seconds) of Completed Tasks for a given role created within the given time window.
pStart and pEnd are in in %TimeStamp format: yyyy-mm-dd
classmethod BamTasksWithStatus(pRole As %String, pStatus As %String, pStart As %TimeStamp = "", pEnd As %TimeStamp = "") as %Integer [ Language = objectscript ]
Calculate the number of Tasks for a given role that have a given status value (e.g, "Cancelled", "Completed") created within the given time window.
pStart and pEnd are in in %TimeStamp format: yyyy-mm-dd
classmethod CompleteTask(pTask As EnsLib.Workflow.TaskResponse, pAction As %String = "") as %Status [ Language = objectscript ]
This Workflow API method marks a task as complete and returns a response to the original requestor.
classmethod CountTasksForCurrentUser() as %Integer [ Language = objectscript ]
Returns count of tasks for the current user.
classmethod FindLeastBusyUser(pRoleName As %String, Output pUserName As %String, Output pCount As %Integer) as %Status [ Language = objectscript ]
Find the name of the highest-ranked, active user within the given role that has the least number of tasks (for any role) assigned to them. On return pCount has current number of tasks for this user.
classmethod ItemExistsForTask(pTask As EnsLib.Workflow.TaskResponse, pUserName As %String) as %Boolean [ Language = objectscript ]
Test if a worklist item exists for the given Task and User name. Put here in order to inline
classmethod SendTask(pTask As EnsLib.Workflow.TaskResponse, pUser As %String, Output pCount As %Integer) as %Status [ Language = objectscript ]
This Workflow API method sends (but does not assign) a Task to a specific User. pUser is the name of the user. On return, pCount is number of users task was sent to.
classmethod SendTaskToAll(pTask As EnsLib.Workflow.TaskResponse, Output pCount As %Integer) as %Status [ Language = objectscript ]
This Workflow API method sends (but does not assign) a Task to all Users within the current Role. On return, pCount is number of users task was sent to.
classmethod SendTaskToTitle(pTask As EnsLib.Workflow.TaskResponse, pTitle As %String = "", Output pCount As %Integer) as %Status [ Language = objectscript ]
This Workflow API method sends (but does not assign) a Task to all Users within the current Role with title pTitle. On return, pCount is number of users task was sent to.
classmethod SendTaskToTop(pTask As EnsLib.Workflow.TaskResponse, pNum As %Integer = 1, Output pCount As %Integer) as %Status [ Language = objectscript ]
This Workflow API method sends (but does not assign) a Task to pNum top ranked Users within the current Role. On return, pCount is number of users task was sent to.
classmethod UnassignTask(pTask As EnsLib.Workflow.TaskResponse, pUser As %String = "") as %Status [ Language = objectscript ]
This Workflow API method unassign a Task associated with specific User. Tests if pUser owns the task (if provided).

Queries

query ListActiveTasks()
SQL Query:
SELECT R.Name As RoleName, (SELECT COUNT(*) FROM TaskResponse WHERE (TaskStatus_RoleName = R.Name) AND (TaskStatus_IsComplete = 0)) As ActiveTasks, (SELECT COUNT(*) FROM TaskResponse WHERE (TaskStatus_RoleName = R.Name) AND (TaskStatus_IsComplete = 0)) / Capacity * 100 As Load FROM RoleDefinition R
Business Activity Metrics query to get information on current task load.
This query returns the number of active tasks for each role.
Use the Bam methods to get this information, not this query.
query ListActiveUsers()
SQL Query:
SELECT Name FROM UserDefinition WHERE IsActive = 1 ORDER BY Name
Returns all users that are active.
query ListCompletedTasks(pStart As %TimeStamp = "")
SQL Query:
SELECT R.Name As RoleName, (SELECT COUNT(*) FROM TaskResponse WHERE (TaskStatus_TimeCreated > :pStart) AND (TaskStatus_RoleName = R.Name) AND (TaskStatus_IsComplete = 1)) As CompletedTasks, (SELECT AVG(DATEDIFF('ss',TaskStatus_TimeCreated,TaskStatus_TimeCompleted)) FROM TaskResponse WHERE (TaskStatus_TimeCreated > :pStart) AND (TaskStatus_RoleName = R.Name) AND (TaskStatus_IsComplete = 1)) As AverageTime, (SELECT MIN(DATEDIFF('ss',TaskStatus_TimeCreated,TaskStatus_TimeCompleted)) FROM TaskResponse WHERE (TaskStatus_TimeCreated > :pStart) AND (TaskStatus_RoleName = R.Name) AND (TaskStatus_IsComplete = 1)) As MinTime, (SELECT MAX(DATEDIFF('ss',TaskStatus_TimeCreated,TaskStatus_TimeCompleted)) FROM TaskResponse WHERE (TaskStatus_TimeCreated > :pStart) AND (TaskStatus_RoleName = R.Name) AND (TaskStatus_IsComplete = 1)) As MaxTime FROM RoleDefinition R
Business Activity Metrics query to get information on completed tasks.
Use the Bam methods to get this information, not this query.
query ListRolesForUser(pUser As %String = "")
SQL Query:
SELECT RoleName, Ranking, Title FROM RoleMembership WHERE UserName = :pUser ORDER BY RoleName
Returns a set of roles for the specified user.
query ListTasksForCurrentUser()
SQL Query:
SELECT %ID As ID, (CASE WHEN IsNew = 1 THEN '*' ELSE NULL END) As New, Task->%Priority As Priority, Task->%Subject As Subject, Left(Task->%Message,25) As Message, Task As TaskId, RoleName, Task->TaskStatus_AssignedTo As AssignedTo, TimeCreated, Age, UserName FROM Worklist WHERE (UserName = USER) AND ((Task->TaskStatus_AssignedTo IS NULL) OR (Task->TaskStatus_AssignedTo = UserName)) ORDER BY TimeCreated DESC
Returns a set of tasks for the current user.
query ListTasksForRole(pRole As %String = "")
SQL Query:
SELECT %ID As TaskId, TaskStatus_RoleName As RoleName, TaskStatus_IsComplete As IsComplete, %Status As Status, %Priority As Priority, TaskStatus_Source As Source, TaskStatus_AssignedTo As AssignedTo, %Subject As Subject, TaskStatus_TimeCreated As TimeCreated, TaskStatus_TimeCompleted As TimeCompleted FROM TaskResponse WHERE TaskStatus_RoleName = :pRole ORDER BY TaskId DESC
Returns a set of tasks for the specified role.
query ListTasksForUser(pUser As %String = "")
SQL Query:
SELECT %ID As ID, (CASE WHEN IsNew = 1 THEN 'New' ELSE '' END) As New, Task->%Priority As Priority, TimeCreated, Age, RoleName, Task->TaskStatus_AssignedTo As AssignedTo, UserName, Task->%Subject As Subject, Left(Task->%Message,25) As Message FROM Worklist WHERE (UserName = :pUser) AND ((Task->TaskStatus_AssignedTo IS NULL) OR (Task->TaskStatus_AssignedTo = UserName)) ORDER BY TimeCreated DESC
Returns a set of tasks for the specified user.
query ListUsers()
SQL Query:
SELECT U.Name, U.FullName, U.IsActive, (SELECT COUNT(*) FROM RoleMembership WHERE UserName = U.Name) As Roles FROM UserDefinition U ORDER BY U.Name
Returns set of all available Users.
query ListUsersForRole(pRole As %String = "")
SQL Query:
SELECT UserName, UserName->FullName As FullName, Ranking, Title, UserName->IsActive FROM RoleMembership WHERE RoleName = :pRole ORDER BY UserName
Returns a set of users for the specified role.
query RolesForUser(pUserName As %String = "")
SQL Query:
SELECT RoleName FROM RoleMembership WHERE UserName = :pUserName ORDER BY RoleName
Returns set of Roles for a given User.
query Tasklist()
SQL Query:
SELECT %ID As TaskId, TaskStatus_RoleName As RoleName, TaskStatus_IsComplete As IsComplete, %Status As Status, %Priority As Priority, TaskStatus_Source As Source, TaskStatus_AssignedTo As AssignedTo, %Subject As Subject, TaskStatus_TimeCreated As TimeCreated, TaskStatus_TimeCompleted As TimeCompleted, DATEDIFF('ss',TaskStatus_TimeCreated,TaskStatus_TimeCompleted) As Duration FROM TaskResponse ORDER BY TaskId DESC
Returns a set of workflow tasks.
query Worklist()
SQL Query:
SELECT %ID As ItemId, Task As TaskId, UserName, RoleName, Task->%Priority As Priority, TimeCreated, Age, Task->TaskStatus_AssignedTo As AssignedTo, Task->%Subject As Subject FROM Worklist ORDER BY TimeCreated DESC
Returns the current worklist contents for all users.

Inherited Members

Inherited Methods (Including Private)

Feedback