Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Need help with Behavior not working as expected.

Wayne Cranford June 28, 2019

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
AUG Leaders

Atlassian Community Events