Hi Everyone,
I need some help with my code. I want to be able to make a custom field mandatory on resolution based on the priority field.
Example if I select priority = 1 then Root Cause field must be mandatory but only on resolution.
I've created a behavior to make the field mandatory but I it applies on edits and I only want it on resolution.
Code:
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.issue.IssueConstantImpl
def priority = getFieldById(getFieldChanged())
def fieldValue = ((IssueConstantImpl) priority.getValue()).getId()
FormField rootcause = getFieldById ("customfield_18900")
if (fieldValue == "2") {
rootcause.setFormValue(-1)
rootcause.setRequired(true)
}
else if (fieldValue == "10101") {
rootcause.setFormValue(-1)
rootcause.setRequired(true)
}
I thought I could do it with a custom script validator on the transition when resolving the ticket but it seems the same syntax doesnt apply when you doing a custom script validator as I get "Cannot Find matching Method" error for this lines in the code:
def priority = getFieldById(getFieldChanged())
def fieldValue = ((IssueConstantImpl) priority.getValue()).getId()
FormField rootcause = getFieldById ("customfield_18900")
Can anyone point me in the right direction
Thanks
Marius
Hi @Marius Pienaar,
It is pretty easy, just place a condition to check screen name in behaviour
I believe you are using transition screen while resolve/close
below snippet may give you some idea
if(getFieldScreen().name == "Resolution Screen name"){
//Then do your actions here
}
BR,
Leo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.