Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Failed to add "Priority" condition to script runner script

Daniel Ziemniak August 22, 2023

Hey everyone.

Right now, when we're transitioning from one status to another, we use this kind of validator, written in script runner:

import com.opensymphony.workflow.InvalidInputException

 

if(issue.resolution.name == "Done" && issue.issueType.name== "UX task" || issue.issueType.name== "Spike")

{

   

}

else if (issue.resolution.name == "Done" && !issue.fixVersions ) {

    throw new InvalidInputException("fixVersions",

        "Fix Version/s is required when specifying Resolution of 'Done' when issue type is not 'UX Task' or 'Spike'")

}

else{

   

}


What does it to, it check status and issue types and throw some info and this is good. I'd like to add another condition - to have "Fix Version" field mandatory to update, but only if request has also certain priority (eg. High). I tried to add something like that into first if:

issue.priority.name == "Release Canceller" || issue.priority.name == "Hotfix")



But it didn't do the trick. Any suggestions?

 

EDIT: I might be dumber than I thought – this condition should be added into second if, as it's the source of the message. Will eventually confirm if this worked.

1 answer

1 accepted

0 votes
Answer accepted
Daniel Ziemniak August 23, 2023

If someone need it:

import com.opensymphony.workflow.InvalidInputException

import com.atlassian.jira.issue.priority.Priority

 

if(issue.resolution.name == "Done" && issue.issueType.name== "UX task" || issue.issueType.name== "Spike")

{

   

}

else if (issue.resolution.name == "Done" && issue.priority.name == "Release Canceller" || issue.priority.name == "Hotfix" || issue.priority.name == "Critical" && !issue.fixVersions) {

    throw new InvalidInputException("fixVersions",

        "Fix Version/s is required when specifying Resolution of 'Done' when issue type is not 'UX Task' or 'Spike'")

}

else{

   

}
Now it works as intended.

Suggest an answer

Log in or Sign up to answer