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 Community Leader Apr 19, 2019

Hi @Kristjan Geir Mathiesen ,

I think this is pretty straightfoward : 

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

Antoine

Wow that was a quick reply @Antoine Berry 

In what Condition option would you use it in?

Thanks,
KGM

Antoine Berry Community Leader 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 Community Leader 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

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;
}

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

Like Kristjan Geir Mathiesen likes this
0 votes

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
Community showcase
Posted in Jira

We want to hear from you! How do you use Slack and Atlassian together?

Hi Everyone! My name is Mina and I am on Atlassian’s Ecosystems Marketing team. Our team is focused on our technology partnerships and marketplace apps. One of Atlassian’s partners is Slack, who ...

85 views 1 5
Join discussion

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