I've done this before with the behavior set based on a single custom field value, but for some reason this isn't working for the combination of field values.
The scenario is that we have an Impact field and an Urgency field. If the highest value in both fields is selected, I want text to display to verify if they are sure about that selection.
Here's what I've tried:
def cf1 = getFieldByName('Impact')
def cf2 = getFieldByName("Urgency")
def cf1Value = cf1.getValue() as String
def cf2Value = cf2.getValue() as String
if(cf1Value == "Critical" && cf2Value == "High"){
cf2.setDescription("warning text")
}
if(cf1Value !="Critical Business/Ops Impact"){
cf2.setDescription("normal description")
}
I've tried adding this to both fields and the behavior does not work on either.
Any suggestions are greatly appreciated!
For your scenario you must add "Urgency" field in behaviour and add script there. Also you must look at changed field. It will do the trick. Every time, when "Urgency" field will change, behavior will trigger again
Try this solution:
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
@BaseScript FieldBehaviours fieldBehaviours
FormField cf1 = getFieldByName('Impact')
FormField cf2 = cfoField = getFieldById(getFieldChanged())
String cf1Value = cf1.getValue() as String
String cf2Value = cf2.getValue() as String
if(cf1Value == "Critical" && cf2Value == "High"){
cf2.setDescription("warning text")
}
if(cf1Value !="Critical Business/Ops Impact"){
cf2.setDescription("normal description")
}
You would indeed need to add that script for both fields, so that it can trigger whenever each of the field is being updated.
You should add some logging to see what values are you getting from FormField#getValue() though because that is probably the reason.
Add this after your getters
log.warn("cf1Value=" + cf1Value)
log.warn("cf2Value=" + cf2Value)
Get the behaviour to run, and then check what you see in the logs if the values are being read as you'd expect.
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.