I'm trying to hide or show a custom filed on a transition screen based on the value of a custom field in the underlying issue. I'm using a ScriptRunner behavior to accomplish this. I am first checking if its the correct transition screen then if the trigger field matches I show the field. if not then its hidden.
here is the code and the logs I get when the code is executed. I cant figure out why TriggerField1 =='Name Check' is equal to false.
import groovy.transform.BaseScript
import com.onresolve.jira.groovy.user.FieldBehaviours
@BaseScript FieldBehaviours fieldBehaviours
final String screenName = 'OSIAP First lvl completed Reviewed by'
//def triggerField = getFieldById('customfield_13022') //Product SubType
if (fieldScreen.name == screenName) {
def fieldtoHide = getFieldById('customfield_13800')
def triggerField1 = underlyingIssue.getCustomFieldValue('Product Subtype')
log.warn(triggerField1)
log.warn(triggerField1 == 'Name Check')
if (triggerField1 == 'Name Check') {
fieldtoHide.setHidden(false)
fieldtoHide.setRequired(true)
log.warn('its working now')
} else {
fieldtoHide.setHidden(true)
fieldtoHide.setRequired(false)
log.warn('not working')
}
}
and here is the log info
2025-04-10T11:45:34,782 WARN [runner.ScriptBindingsManager]: Name Check 2025-04-10T11:45:34,783 WARN [runner.ScriptBindingsManager]: false 2025-04-10T11:45:34,783 WARN [runner.ScriptBindingsManager]: not working
for anyone in the future I figured it out. It was a simple data mismatch. I changed the triggerField1 value to a string and its working.
final String triggerField1 = underlyingIssue.getCustomFieldValue('Product Subtype')
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.