Jira custom field behavior does not work with different field configurations Edited

Hi everyone,

i wrote a script for a custom field to show or hide it based on another custom field value. The script works perfectly fine, when i create an issue and the field configuration for the issue is directly the one the fields are used in.

If the create screen starts with a different issue type or project (so of course a different field configuration) and i change to the right project and issue type, the script does not work. 

I put the script in all field configurations to the custom field, so I don't know why Jira does not uses it.

The script I put in the description of the custom field (in every field configuration) is this:


<script type="text/javascript">


jQuery(document).ready(function($) {

JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) {



  function callChangeFunction() {


    // dropdown custom field change function

    $("#customfield_10027").change(function() {





function showHidField() {

    //drop down field selected value

    var dropDownFieldval =$("#customfield_10027").val();

    //test field1




        if($(this).attr('for') == 'customfield_10404'){




    if(dropDownFieldval != '10063' && dropDownFieldval != ''){


        if($(this).attr('for') == 'customfield_10404'){





        $("#customfield_10404").css("border", "2px solid red");







2 answers

1 accepted

1 vote
Accepted answer

Hi Chiara,

I understand what you are trying to accomplish, but I do not know why this must be done in JavaScript. Why not add server-side Groovy code for the behaviour attached to the field you want to modify?

For instance, you could write something like this. 

  1. Code attached to a Select List Field
  2. Check value of the Select List Field
  3. If it's not a certain value, hide another custom field
def selectField = getFieldById(getFieldChanged())
def selectValue = cascadingField.getValue()

def customField = getFieldById("customfield_11906") // name of custom field to hide here

if (selectValue == "Some Value") {

There are more examples of this type of code in our documentation


Hi Joshua,

If I put the code at the same place (description of the custom field), it does not change the final result. If I create an issue and a field configuration is loaded, where the custom field is not on the create screen, and then select the issue type, where the custom field is on the create screen, the behavior of the field does not work. It ist not even loaded (I checked it with the browser console).


Could you please clarify?

  1. Are you using ScriptRunner? If so, which version of ScriptRunner?
  2. Why must this be done in JavaScript if you are using ScriptRunner?

Showing or hiding a custom field based on the value of another field is a very basic feature of ScriptRunner Behaviours. It should not be very hard to accomplish with just a few lines of code.

I created the following behaviour, mapped to my project and specific issue type:

Screen Shot 2017-09-05 at 8.48.29 AM.pngThen, I added a field to this behaviour. Because I want to check the values of my Select List, I added my "SelectListA" field to the behaviour.

Then I added this server-side script to the SelectListA field:

def selectField = getFieldById(getFieldChanged())
def selectValue = selectField.getValue()

def customField = getFieldByName("TextFieldA") // name of custom field to hide here

if (selectValue == "AAA") {
else {

It gets the value of my SelectListA field. It checks to see if the value of SelectListA matches 'AAA'. If it matches, hide my other custom field named 'TextFieldA'. If it does not match, do not hide it.

Screen Shot 2017-09-05 at 8.47.58 AM.pngThere is no code being placed in the descriptions of the custom fields.

Hi Joshua,

i understand what you wanted to me to do now. It's really much easier this way und it works perfectly fine now. 

Thank you very much for your help!

If I check the browser console, the following ist shown:

Empty String  handed over to getElementById() 

I assume that the script cant find the custom field, because it is not part of the create screen, but how can I avoid this behavior? It does not help to put the fields on the create screen and hide them in the field configuration.

The script should check, if the custom field is there, when changing the issue type.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,279 views 5 10
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you