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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

568 views 15 18
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you