Condition transition (hide it) to Priority = Critical

Kristján Geir Mathiesen
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 19, 2019

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 19, 2019

Hi @Kristján Geir Mathiesen ,

I think this is pretty straightfoward : 

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

Antoine

Kristján Geir Mathiesen
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 19, 2019

Wow that was a quick reply @Antoine Berry 

In what Condition option would you use it in?

Thanks,
KGM

Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 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

Kristján Geir Mathiesen
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 19, 2019

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
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 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.

Kristján Geir Mathiesen
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 19, 2019

@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
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 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.

Kristján Geir Mathiesen
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 19, 2019

Thanks @David Fischer  

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

KGM

0 votes
Kristján Geir Mathiesen
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 19, 2019

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
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 19, 2019

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

Suggest an answer

Log in or Sign up to answer