It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Prevent user from moving ISSUE between all states

Casey Daniell Nov 13, 2015

In our Orig we are trying to avoid formal roles like DEV and QA. Is it possible to use Scriptrunner to control transitions between statuses, and prevent the same person from moving an ISSUE between all statuses. 

For example, I want DEV A to move a STORY to RESOLVED, but not the next state of VALIDATED, which he must ask DEV  B to do after checking his work. In another ISSUE though DEV B may move the ISSUE to RESOLVED, and DEV A QA's the work moving it to VALIDATED.

Ideally, it's a very simply JQL query to determine who moved the ISSUE to one RESOLVED and prevent that same user from moving it to VALIDATED too. 

(I know we can do this by assigning users to static roles then only allowing users in a role to perform the transition – this isn't what I want to manage)

3 answers

1 vote
JamieA Nov 15, 2015

You could put the following code as a simple scripted condition on the Validate action:

import com.atlassian.jira.component.ComponentAccessor

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def changeHistories = changeHistoryManager.getChangeHistories(issue)

def currentUserKey = ComponentAccessor.getJiraAuthenticationContext().getUser()?.key

// returns true if there are no transitions to the target state by the current user
passesCondition = ! changeHistoryManager.getAllChangeItems(issue).find {
    it.field == "status" &&
        currentUserKey == it.userKey &&
        "Resolved" in it.toValues.values()
}
0 votes
James Strangeway Community Leader Nov 13, 2015

You can add a "separation of duties" condition to the transition of the workflow.  This is built in and should get you what you are looking for.

 

Hope this helps.

Cheers!

0 votes
Geoff Wilson Nov 13, 2015

You may have already seen this, but in a Workflow's Transition's Condition you can select one of these, such as "Only Reporter Condition" so that only allow the reporter to execute this next transition (ex: if your DEV A wrote a Task and DEV B worked on it, only DEV A can set the next workflow transition to say Completed once they review it).

Add Condition To Transition

 NameDescription
Transition to execute only if code has/has not (depending on configuration) been committed against this issue.
Condition to hide a transition from the user. The transition can only be triggered from a workflow function.
Transition to execute only if there are no related open Crucible reviews.
Condition to allow only the assignee to execute a transition.
Condition to allow only the reporter to execute a transition.
Condition to allow only users with a certain permission to execute a transition.
Runs a script to evaluate whether to allow this action, or a built-in script.
Condition to block parent issue transition depending on sub-task status.
Transition to execute only if there are no unreviewed changesets related to this issue.
Allows only users of a given group to execute the transition.
Allows only users of a given role to execute the transition.
Allows only users in a given custom field to execute the transition.
Condition to allow only users in a given group to execute a transition.
Condition to allow only users in a custom field-specified group to execute a transition.
Condition to allow only users in a given project role to execute a transition.
Allows to execute a transition if the given value of a field is equal to a constant value, or simply set.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

Join our webinar: “Asset Management: The Role of Context in ITSM” with Atlassian & Riada

  Hi Atlassian Community! This is Teresa from the Jira Service Desk team. On June 19th, I’ll be hosting a webinar “Asset Management: The Role of Context in ITSM” with Atlassian Partne...

137 views 1 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you