Hi Community,
I need a behaviour, mapped to a issuetype in a project, so that when clicking on "Create" and select this project and issuetype, there are 3 custom fields that must be displayed in the screen, only if I select a specific value on other cascading custom field. I thought it was an easy thing, but it is not working. In Initialiser, I have put this code:
if (getActionName() in ["Create Issue", "Create"]) {
def fieldToHide1 = getFieldByName("Risk")
def fieldToHide2 = getFieldByName("Vul")
def fieldToHide3 = getFieldByName("Group")
fieldToHide1.setHidden(true)
fieldToHide2.setHidden(true)
fieldToHide3.setHidden(true)
fieldToHide1.setRequired(false)
fieldToHide2.setRequired(false)
fieldToHide4.setRequired(false)
def cfield = getFieldByName("Source")
Map mapValue = cfield.getValue() as Map
if (mapValue.get(1) == "SUR") {
fieldToHide1.setHidden(false)
fieldToHide2.setHidden(false)
fieldToHide3.setHidden(false)
fieldToHide1.setRequired(true)
fieldToHide2.setRequired(true)
fieldToHide3.setRequired(true)
}}
Please, I appreciate any help. Thanks!
Hi, finally I got it!
I put this code in a server-side script for the specific field that makes the other change.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.fields.CustomField
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.*
@BaseScript FieldBehaviours fieldBehaviours
FormField field = getFieldById(getFieldChanged())
FormField fieldToHide1 = getFieldByName("Level")
if (getActionName() in ["Create Issue", "Create"]) {
fieldToHide1.setHidden(true)
fieldToHide1.setRequired(false)
def value = field.getValue() as List
if (value.toString().contains("high")) {
fieldToHide1.setHidden(false)
fieldToHide1.setRequired(true)
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.