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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Behaviours: How to make custom field required when I select a specific radio button option?

Version - Behaviours with Jira v8.5.1 

I have been using a Beavhiours script for several months now with great success. It currently shows/hides various fields based on user selections (lists, cascading lists, checkboxes). I want to condition the required/optional condition of a text field based on the value of a radio button.

IS: Text field required status not changing when I make correct radio button selection
SHOULD BE: Text field should become required when I select specific radio button

Goal: Use Adaptavist Behaviours to make textField required when both 1. a radio button (radioField) and 2. a cascading list (listField) meet a certain selection condition.

Here is my sample code in one of the Behaviours "Fields":

// set pointers to custom fields (list, radio button, and text)
def listField = getFieldByName ("My List")
def radioField = getFieldByName ("My Radio")
def textField = getFieldByName ("My Text")

// get cascading list value (parent and child)
String listString = listField.getValue()
// if cascading list matches one of two selections, show the radio button field
if ((listString == "[Parent1, Child1]") || (listString == "[Parent1, Child2]")) {
    radioField.setHidden(false)
} // otherwise, hide the radio button field
else {
    radioField.setHidden(true)
}
// get the value of the radio button field
String radioString = radioField.getValue()
// if both the cascading list and radio button value match specific values, make the text field required
if ((listString == "[Parent1, Child1]") && (radioString == "Radio Option")) {
    textField.setRequired(true)
}
// in all other cases, make the text field optional
else {
    textField.setRequired(false)
}

 

This code works except for making the text field required. I can get the text field to become required with the following steps:
1. Set listString to "[Parent1, Child2]"
2. Set radioString to "Radio Option"
3. Set list string to "[Parent1, Child1]"
In this case, we choose one list option that shows the radio button field but does not meet the conditions for making the text field required ("[Parent1, Child2]"). Then we can set the radio button to the correct option. Then set the list option to the one that meets the 2nd condition of making the text field required ("[Parent1, Child1]").

Given this behavior, it seems like the radio button field value is only being updated when I change the list field selection. But shouldn't it be independent of my list selection?

Additional information:
None of my radio buttons will update their value when I change the selection. I determined this by using log.warn on the radio button value and then checking the print statements in the last several lines of "atlassian-jira.log of the built-in script "View server log files". The radio button stays at its default.

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Jira Cloud Performance Improvements

Hello everyone, I am a product manager in the Jira Cloud team focused on making sure our customers have a delightful experience using our products. Towards that goal, one of the areas which is extr...

170 views 2 9
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