Warning: Despite our best efforts, code can change without notice due to a variety of factors. If you encounter an issue in any of the code shown here and find that a specific block of code is not correct, or is causing errors, please check with the Community to find an updated version.
When configuring a workflow orchestration between two projects, it must be possible to progress an issue from one status to another status using a correct transition.
This transition can be triggered by calling the workflowHelper.transition method in the Create and/or Change processor.
1 # 2 # When the remote issue has status 'closed', progress this issue to status closed 3 # 4 if (replica.status.name == "Closed") { 5 workflowHelper.transition(issue, "Closed") 6 }
A more elaborate example where the local status is set to a specific status depending on the remote status:
When | Then |
---|---|
Remote status = 'Assigned to Supplier' | Local status should be set to 'Open' |
Remote status = 'Quoted' | Local status should be set to 'Quoted' |
Remote status != 'Assigned to Supplier' and != 'Quoted' | Local status should be set to 'Processed'.
The resolution should either be set to 'Pending' if the remote resolution is not set, else to 'Fixed' if the remote resolution is set |
1 if (replica.status.name == "Assigned to supplier" && issue.status.name != "Open" ) { 2 // issue is assigned to supplier, so it should be opened 3 workflowHelper.transition(issue, "autoopen") 4 } else if (replica.status.name == "Quoted" && issue.status.name != "Quoted" ) { 5 // issue has been quoted on the remote side, so it needs to be moved into status quoted here also 6 workflowHelper.transition(issue, "autoquote") 7 } else if (replica.status.name != "Assigned to supplier") { 8 if (replica.resolution.name == "NULL") { 9 log.info("Transitioning using 'autopending'") 10 workflowHelper.transition(issue, "autopending") 11 } else { 12 log.info("Transitioning using 'autoresolve'") 13 workflowHelper.transition(issue, "autoresolve") 14 } 15 }
Note:
- Ensure that the transition has no screens, validators and conditions enabled.
- Hide the transition for other users than the proxy users.
- The transition will only be triggered if it exists in the status of the local issue.
- No error is raised if the transition doesn't exist, or fails to execute.
- the transition is applied once that all other issue changes have been applied. So it doesn't matter where the workflowHelper.transition is called.