Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,368,408
Community Members
 
Community Events
168
Community Groups

Need help with Behavior not working as expected.

Environment:
JIRA v7.4.4, 
ScriptRunner 5.3.5

Using the below, upon creation of the issue I expect the custom field (Support Forum Post Location) to only appear when one of components are selected, and then it should be required. 

What is happening is the custom field does not appear initially  on the create screen (expected) but also does not appear if I select either of the two components and try to create, the issue is created without showing and requiring the custom field.

If I edit an issue created like this, then the field is required as expected.

However, if I try to create with the Summary blank and one of the Component selected, then custom field appears and is required. 

I am not using an Initialiser Function or "new condition", and have tried with the Use Validator Plugin enabled and disabled.

While we have  experimented with Behaviors, this is the first need to get this up and running.

Thanks

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.getCustomFieldManager()

def hidefield = getFieldByName("Support Forum Post Location")
def component = getFieldById("components")
def componentV = component.getValue()


if (componentV.toString().contains("Customer Experience Process Improvement")) {
hidefield.setRequired(true)
hidefield.setHidden(false)
hidefield.setHelpText("This field is required when a Customer Experience issue is created")
}
else if (componentV.toString().contains("Customer Experience Support Community Item")) {
hidefield.setRequired(true)
hidefield.setHidden(false)
hidefield.setHelpText("This field is required when a Customer Experience issue is created")

} else {
hidefield.setHidden(true)

}

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events