How to enable/disable custom field based on another custom field values? [Jira] [Behavior]

Teja August 7, 2019

Hi Team,

  1. We have a field called Launch Type (Select List CF) on create screen right below the Roadmap Item Type (Select List CF) field.
  2. Launch Type values are 'Major' and 'Minor'.  
  3. Roadmap Item Type values are 'ABC' and 'XYZ'.
  4. On the Create screen, if Roadmap Item Type = 'ABC',  Launch Type field is enabled. 
  5. If Roadmap Item Type = 'XYZ', disable/gray out the Launch Type field.

How to achieve this using behavior script or any java-script?

Thanks in advance

3 answers

1 accepted

1 vote
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.
August 7, 2019

Hi @Teja ,

  • Go to behaviours -> Add new behaviour
  • Map this behaviour to Project/Issuetype
  • Click "fields" than Select a field (ex; Roadmap Item Type)
  • Add server-side script
  • Paste your code.

Following script may help you.

def roadMapField = getFieldById("customfield_xxxxxx") 
def launchTypeField = getFieldById("customfield_xxxxxx")

String roadMapVal = roadMapField.getFormValue();

if(roadMapVal.equals("ABC")){
launchTypeField.setRequired(true);
} else {
launchTypeField.setRequired(false);
}

There are lots of methods that you can use in behaviours, please check this link.

Regards

Teja August 7, 2019

Hi @Tansu Akdeniz 

Thank you for your swift reply,

I rephrased my question body.

Initially I wanted to enable/disable Launch Type field based on the selection Roadmap Item Type value. I will do the validation later using 'Validators' on create screen.

Ex: If Roadmap Item Type = "ABC" then enable Launch Type field.

If Roadmap Item Type = "XYZ" then readonly Launch Type field.

 

def roadMapField = getFieldById("customfield_xxxxxx") 
def launchTypeField = getFieldById("customfield_xxxxxx")

String roadMapVal = roadMapField.getFormValue();

if(roadMapVal.equals("XYZ")){
launchTypeField.setReadOnly(true);
} else {
launchTypeField.setReadOnly(false);
}

The above code did not work.

Am I doing anything wrong?

Roadmap.PNG

Regards

Tejas 

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.
August 7, 2019

Hi @Teja ,

You can use this one in order to implement this scenerio.

If Roadmap Item Type = "Tactical" then make Launch Type field enabled.

def roadMapField = getFieldById(getFieldChanged())
def launchTypeField = getFieldById("customfield_15400")

String roadMapVal = roadMapField.getFormValue();

if(roadMapVal.equals("Tactical")){
   launchTypeField.setReadOnly(false);
} else {
   launchTypeField.setReadOnly(true);
}

Regards,

Teja August 8, 2019

Hi @Tansu Akdeniz 

It worked. 

Ton of thanks

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.
August 8, 2019

Glad to hear that @Teja :)

0 votes
Anusha Iyer April 11, 2022

Hi @Teja

Could you please help me to keep a field available with other field's value?

Only when  user set the Automation Status as Automated, Test Cases Reference will be shown below the Automation Status.

Thanks,
Anusha

image-2022-04-08-18-39-19-119.png

0 votes
Aisha M October 14, 2020

Hi @Tansu Akdeniz  Can Behaviours be used to display a field for specific projects alone & not be visible to every project ,after adding the field to the Issue type screen ? I'm looking for an alternative to using the usual options. Thank you

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.
October 14, 2020

Hi @Aisha M 

Behaviors configuration is mapped to projects. If you hide a field in certain projects, it won't be visible in these projects screens.

For example, assume that we have 3 projects sharing same screen schemes and we want to make a field hidden in two of them. Then map the behaviors to those two projects and hide the field.

Regards

Aisha M October 14, 2020

Hi @Tansu Akdeniz  Thank you for the comment. So, if I have >40 projects & want the field to be visible in just 5 projects, then how can I make it happen using behaviors ? I guess selecting >35 projects should be tedious :) Or is there is a way to selected all projects & deselect a few 

Also, is there is a way to like selected ALL PROJECTS & the issue type. & then have a script or something to enable the field in certain projects & disable in others or something ? Thank you

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.
October 15, 2020

Hi @Aisha M 

You have to select all those projects manually and make the field hidden in bhv configuration. I do not know an easy way for mapping projects. Another traditional option is to split screen schemes between the projects.

Yes, it is possible. You can map to all projects then filter in your custom script if you are familiar with scripting.

Aisha M October 16, 2020

@Tansu Akdeniz Thank you for the comment.

Suggest an answer

Log in or Sign up to answer