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

Condition transition (hide it) to Priority = Critical

Hi all.

So I want to use a Groovy script to hide a transition from issues that have Priority = Critical (or Priority = High but let's start with Critical). I.e. use this script as a Condition.

I've searched a bit but not found exactly this use case. Any ideas?

TIA,
KGM

3 answers

1 accepted

0 votes
Answer accepted
Antoine Berry Apr 19, 2019

Hi @Kristjan Geir Mathiesen ,

I think this is pretty straightfoward : 

if (issue.getPriority().getName() == "Critical"){
passesCondition = false
}
else {
passesCondition = true
}

Antoine

Kristjan Geir Mathiesen Apr 19, 2019 • edited

Wow that was a quick reply @Antoine Berry 

In what Condition option would you use it in?

Thanks,
KGM

Antoine Berry Apr 19, 2019

I see you have figured it out as well. :)

This script was for ScriptRunner, but for JMWE (Scripted condition) it is even easier : 

issue.getPriority().getName() != "Critical" && issue.getPriority().getName() != "High"

I guess you could use Value Field as well, but this is a different plugin right (JSU) ?

Antoine

Like Kristjan Geir Mathiesen likes this

Ah, I see now. Thanks so much for your willingness to help, @Antoine Berry 

Yeah I had a breakthrough after merging and mixing code from other use cases that I searched in the Community :)

KGM

Like Antoine Berry likes this
Antoine Berry Apr 19, 2019

Glad to help. :) I guess people indeed assume scriptrunner when you are talking about groovy script.

You may accept the answer if you are satisfied with it.

Like Kristjan Geir Mathiesen likes this

@Antoine Berry  that was a very simple line for JMWE! But needed your help for such a simple code. Look at all my lines :)

Thanks so much and have a great weekend!
KGM

Like Antoine Berry likes this
0 votes

I just figured it out! I used the following script in Jira Misc Workflow Extentions (JMWE) plugin for this. Might be importing too many classes but it works :)

import com.atlassian.jira.bc.projectroles.ProjectRoleService;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.jira.security.roles.ProjectRole;
import com.atlassian.jira.security.roles.ProjectRoleActors;
import com.atlassian.jira.security.roles.ProjectRoleManager;
import com.atlassian.jira.security.roles.RoleActor;
import com.atlassian.jira.issue.*

Issue issueKey = issue
def priority = issue.getPriority().getName()

if (priority == "Critical") {
return false;
}
else if (priority == "High") {
return false;
}
else {
return true;
}

David Fischer [Innovalog] Community Leader Apr 19, 2019

Actually, you didn't need any import for these lines of code :) 

Like Kristjan Geir Mathiesen likes this
0 votes
David Fischer [Innovalog] Community Leader Apr 19, 2019

Hi Kristjan,

actually, you should have mentioned that you were using JMWE. The answer is actually very simple:

! (issue.getAsString("priority") in ["Critical","High"])

You could actually have figured out most of it (just not the "in" part) simply by looking at the "Issue Fields" help tab below the editor.

Thanks @David Fischer [Innovalog]  

P.s. Very nice to meet you in person last week at the Summit.

KGM

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 Jira

Try Jira Cloud for Outlook: Organize your work without leaving your inbox

Hi Atlassian community, My name is Max and I work on the product integration team at Atlassian. I am pleased to announce the early access program for the Jira Cloud add-in for Outlook. This add-in...

2,002 views 5 15
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