Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How to use transition in the Scriptrunner Separation of Duties script?

Edited

I currently am using Scriptrunner's provided script for separation of duties found here: https://docs.adaptavist.com/sr4js/latest/features/workflows/conditions/built-in-conditions/simple-scripted-condition (script below).

The problem is that this script uses status where I want to use a transition.  I tried changing it from status to transition in the script and while the script didn't give an error, it didn't work either.  My end goal is a workflow condition that will not show the transition to the current user if a specific previous transition was used by that user.  That way the person doing the work can't also approve the work.

The original script is:

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()
}

 

1 answer

1 accepted

0 votes
Answer accepted

The answer, in case anyone else has this use case, is to check for the "from" status as well as the "to" status, like this:


it.field == "status" &&
currentUserKey == it.userKey &&
"In Progress" in it.fromValues.values() &&
"Resolved" in it.toValues.values()
 

In this example, it's checking for any transition from "in progress" to "resolved".

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events