Hello,
I think I have the solution, but I don't understand why it's not working on my project. Maybe I miss something. Please tell my if script something wrong.
Context : According to a choice made with the field security level, I want to display or not a multi user field.
Method : I put a script I find on internet in the description of my field (I tried both).
According to JQL, Security level = 'Level' and The choice in Security Level I want = '10105'. (Maybe I'm wrong ?)
I tried 2 differents scripts :
<script type="text/javascript"> security = document.getElementById('level'); if(security) { target = document.getElementById('customfield_ 10530'); // Hide the target field if priority isn't critical if (security.value != '10105')) target.style.display='none'; security.onchange=function() { if (this.value == '10105') { target.style.display =''; } else { target.style.display='none'; } } } </script>
And this one (a lot of comment):
<script type="text/javascript"> /*--------- Use Case ----------- Only show targetField when the changingField is set to desiredValue. You'll need to configure these options yourself. ----------- This is using basic javascript and the jquery library provided by atlassian. This should be within the Field Description, within the Field Configuration. The jQuery can be accessed using the AJS.$wrapper.*/ //Obtain the first field by ID changingField = document.getElementById('level'); //Start our process if the field is present if (changingField) { //Desired value to show the targetfield desiredValue = '10105' //Obtain the second field by ID targetField =document.getElementById('customfield_10530'); // This first if-statement will hide the target field immediately, unless the default value is set to our desired value // Hide the target field's container if changing field isn't set the desired value if (changingField.value != desiredValue) AJS.$(targetField).parent().hide() // onchange runs when a select field changes. Basic logic here shows it for desired value, hides it for all else // Be sure to set the field to nothing when using the else clause to hide the field container, otherwise you'll still submit data changingField.onchange=function() { if (this.value != desiredValue) { AJS.$(targetField).parent().fadeIn(200, "jswing" ) } else { targetField.value=''; AJS.$(targetField).parent().fadeOut( 200, "jswing" ) } } } </script>
Thanks for your help
Community moderators have prevented the ability to post new answers.
What is strange is that the second script work with two other customfield only if they are on a second tab but it still doesn't work with one of my target field (security level and multi group picker) ...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I try another way : With groovy and behaviours on a field (I put script in 'security level' field).
I tried this script but it doesn't work either. Do you see something wrong in the script ?
def otherField = getFieldByName(
"Groupes autorisés"
)
def faveGroupeField = getFieldById(getFieldChanged())
def selectedOption = faveGroupField.getValue() as String
def isOtherSelected = selectedOption ==
"4 - Définir"
otherFaveField.setHidden(! isOtherSelected)
otherFaveField.setRequired(isOtherSelected)
Thanks