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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,559,390
Community Members
 
Community Events
184
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
AUG Leaders

Atlassian Community Events