Workflow
Purpose¶
Access and control of Workflow Steps service behaviour.
Methods¶
Binding name: p6.workflow
Method: Map localeText(stepXml, ConfigXpath)
Reads a workflow step i18n format into a Map.
The ConfigXpath
syntax is not standard XPath but a variant supported by Apache Configuration.
Typically this method is used from the workflow task enhancement script as specified in the step XML.
<WorkflowTaskEnhancer script="AwfWorkflowTaskEnhancer"/>
Method: List<String> stepNames
Returns a list of all workflow step names.
Method: List<Map> assignees(String stepName)
Returns a list of workflow users who have been identified as assignees for the requested workflow step.
Method: boolean isAssignee(String userEmail)
Returns true
if the supplied email address resolves as a workflow assignee
Note
Forces the examination of all current workflow tasks.
Method: syncAssignees(Closure itemNotifier)
Will synchronize all open and active workflow tasks and transactions with the workflow task embedded (inline) XML workflow step definition assignees.
This method will enumerate all open and active workflow tasks, parsing the embedded workflow step XML and resolving the assignee definition in each.
The new assignee(s) will be used to replace current assignees in the workflow task and linked transaction.
Unlike the syncAssignees()
method call, each call to this method will reevaluate all workflow tasks every time.
Note
This method can result in a lot of processing as all serialized step definitions must be re-evaluated.
This is useful when a large number of workflow tasks exist and new assignee team members are added/removed. Otherwise, active workflow task visibility rules will not reflect the current organisational structure.
The itemNotifier
closure is optional but allows display of per item transactions and the pacing of the sync process.
This closure should return true. Returning anything else will terminate the sync process.
Note
Pacing can be performed by inserting a sleep()
statement of the desired duration within the supplied closure.
Note
If the calculated assignees have not changed since the method was called previously, this method will do nothing.
Examples¶
def statusMap = p6.workflow.localeText stepXml, "StatusLabels/Label[@name=REVIEWED']"
p6.pipeline.put "ReviewedStatus", statusMap, "application/p6core.i18n"
p6.workflow.stepNames().each() {
def stepName = "${it}"
println stepName
p6.workflow.assignees(stepName).each() {
println "${it}"
}
p6.workflow.uncheckedAssignees(stepName).each() {
println "${it}"
}
}
if(p6.workflow.isAssignee("simon.temple@amalto.com")){
println("Simon is an assignee")
}
p6.workflow.syncAssignees(){id, msg ->
println "----> Syncing work item: " + id + ", Message: " + msg
true
}