Simple Scripted Condition
Examining the Issue History
Separation of Duties
Sometimes you want different people from the same group or role to execute different steps of the workflow. For example, the person that resolved an issue should not be the same person that validates the fix.
You can put the following code as a condition on the Validate action, which will prevent the same user that did the Resolve action from validation:
import com.atlassian.jira.component.ComponentAccessor def changeHistoryManager = ComponentAccessor.getChangeHistoryManager() def currentUserKey = ComponentAccessor.getJiraAuthenticationContext().getUser()?.key // returns true if there are no transitions to the target state by the current user !changeHistoryManager.getAllChangeItems(issue).find { it.field == "status" && currentUserKey == it.userKey && "Resolved" in it.toValues.values() }
All Sub-tasks assigned to me
You can use a condition to check that all sub-tasks are assigned to the current user before the parent task can be transitioned:
groovy// Retrieve the current logged in user using a different variable name def loggedInUser = Users.getLoggedInUser() // Retrieve all sub-tasks of the current issue def subTasks = issue.getSubTaskObjects() // Check if all sub-tasks are assigned to the logged in user def allAssignedToLoggedInUser = subTasks.every { subTask -> subTask.assignee?.username == loggedInUser.username } // Return true if all sub-tasks are assigned to the logged in user, false otherwise return allAssignedToLoggedInUser