EnsLib.Workflow.Engine
class EnsLib.Workflow.Engine extends %Library.RegisteredObject
Provides the core APIs for the Ensemble Workflow system.Method Inventory
- %CancelRequest()
- %CreateObject()
- %DistributeTask()
- %OnRoleChange()
- %OnRoleMembershipChange()
- %OnUserChange()
- %ProcessAction()
- %RelinquishOwnershipForTask()
- %TakeOwnershipForTask()
- AssignTask()
- BamActiveLoad()
- BamActiveTasks()
- BamAvgTaskTime()
- BamCompletedTasks()
- BamMaxTaskTime()
- BamMinTaskTime()
- BamTasksWithStatus()
- CompleteTask()
- CountTasksForCurrentUser()
- FindLeastBusyUser()
- ItemExistsForTask()
- SendTask()
- SendTaskToAll()
- SendTaskToTitle()
- SendTaskToTop()
- UnassignTask()
Methods
classmethod %CancelRequest(pRequest As TaskRequest) as %Status
Cancel a workflow task.
Called when original request times out.
classmethod %CreateObject(pClass As %String) as %RegisteredObject
Helper method to create an object instance given a class name.
classmethod %DistributeTask(pRoleName As %String, pRequest As TaskRequest, pToken As %String) as %Status
Takes a Task and distributes it, via a Task object, to a role.
Called by Workflow operation when a new task arrives.
Notification that a Role definition has been changed.
Possible values for pReason are:
Possible values for pReason are:
- $$$WfRoleDeleted--The role has been deleted.
classmethod %OnRoleMembershipChange(pRoleName As %String, pReason As %String, pUserName As %String) as %Status
Notification that the Role membership has been changed.
Possible values for pReason are:
Possible values for pReason are:
- $$$WfUserAddedToRole--A user has been added to the role.
- $$$WfUserRemovedFromRole--A user has been removed from the role.
Notification that a User definition has been changed.
Possible values for pReason are:
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
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
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
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
This Workflow API method assigns a Task to a specific User.
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
Active Load is the number of active tasks expressed as a percentage of the given role's capacity setting:
ActiveLoad = (ActiveTasks / Role.Capacity) * 100
Calculate the number of Active Tasks for a given role.
Active Tasks is the number of tasks that are not marked as complete.
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
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
pStart and pEnd are in in %TimeStamp format: yyyy-mm-dd
classmethod BamCompletedTasks(pRole As %String, pStart As %TimeStamp = "", pEnd As %TimeStamp = "") as %Integer
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
pStart and pEnd are in in %TimeStamp format: yyyy-mm-dd
classmethod BamMaxTaskTime(pRole As %String, pStart As %TimeStamp = "", pEnd As %TimeStamp = "") as %Integer
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
pStart and pEnd are in in %TimeStamp format: yyyy-mm-dd
classmethod BamMinTaskTime(pRole As %String, pStart As %TimeStamp = "", pEnd As %TimeStamp = "") as %Integer
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
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
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
pStart and pEnd are in in %TimeStamp format: yyyy-mm-dd
classmethod CompleteTask(pTask As EnsLib.Workflow.TaskResponse, pAction As %String = "") as %Status
This Workflow API method marks a task as complete and
returns a response to the original requestor.
classmethod CountTasksForCurrentUser() as %Integer
Returns count of tasks for the current user.
classmethod FindLeastBusyUser(pRoleName As %String, Output pUserName As %String, Output pCount As %Integer) as %Status
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
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
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
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
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
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
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
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.
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
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
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.
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
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
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
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
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
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
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
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
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
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
- %AddToSaveSet()
- %ClassIsLatestVersion()
- %ClassName()
- %ConstructClone()
- %DispatchClassMethod()
- %DispatchGetModified()
- %DispatchGetProperty()
- %DispatchMethod()
- %DispatchSetModified()
- %DispatchSetMultidimProperty()
- %DispatchSetProperty()
- %Extends()
- %GetParameter()
- %IsA()
- %IsModified()
- %New()
- %NormalizeObject()
- %ObjectModified()
- %OriginalNamespace()
- %PackageName()
- %RemoveFromSaveSet()
- %SerializeObject()
- %SetModified()
- %ValidateObject()