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
I think this is pretty straightfoward :
if (issue.getPriority().getName() == "Critical"){
passesCondition = false
}
else {
passesCondition = true
}
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually, you didn't need any import for these lines of code :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.