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,552,334
Community Members
 
Community Events
184
Community Groups

Way to make one field required based on another field selection using scriptrunner behaviors

I have a required field called "Release Type" and when it is set to "Hardware" I want to have the SKU(s) field required.  When it is set to anything else, I want the SKU(s) field optional and read only or if possible hidden.  Here is the script I have so far but it isn't working at all.  I also want the asterisk to show against skus as well if possible.

 

def releaseTypeField = getFieldById(getFieldChanged())

def releaseTypeStatus = releaseTypeField.getValue()

def skusField = getFieldById("SKU(s)")

if (releaseTypeStatus == "Hardware") {
    skusField.setRequired(true) //Sets the SKUs field to required.
    skusField.setHelpText("The SKUs field is required when it is a hardware project")
}
else {
    skusField.setRequired(false) //Sets the SKUs field back to optional
    skusField.setReadOnly(true)
    skusField.setHelpText("")
}

 

1 answer

1 accepted

0 votes
Answer accepted
Tansu Akdeniz
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 25, 2023

Hi @Joe Harmon 

You use getFieldById but you provided cf name. Use getFieldByName or provide ID of the field.

def skusField = getFieldById("SKU(s)")

Also, use formField.setHelpText() to see the values in UI for testing.

Ex; releaseTypeField.setHelpText(releaseTypeStatus)

For further info:

That's what it was.  I saw an example from someone and that is what they used and had the name on it.  I was confused by that as I figured it had to the be the customfieldID_xxxx.  Oh well, thanks for helping me with it.

Tansu Akdeniz
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 26, 2023

Glad to hear that, you are welcome!

I tried to add a second field with the same context as the first and it only worked on the first.  You ever heard of that before?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events