Hi
i would liketo hide some fields (or tab if this is possible) if in another field is something
i found this script :
<script type="text/javascript">
priority = document.getElementById('priority');
if (priority) {
target = document.getElementById('customfield_10142');
// Hide the target field if priority isn't critical
if (priority.value != 2) target.style.display='none';
priority.onchange=function() {
if (this.value == 2) {
target.style.display = '';
target.value="enter message here";
} else {
target.style.display='none';
}
}
}
</script>
And this is working but only in a new window, if i'm creating issue in pop-up window its not working.
I'm putting this script in description of custom field.
I would like do this without plugins.
Thanks
That makes sense. The popup ( js) is only loaded once.
Select the correct project and issue type (with applicable js) in the popup. Close and reopen the popup. The js should work only when customfield_10142 is already present on the form when you open the popup. If you have to change the project/issue-type in the popup, your js has already failed before that.
As a workaround you can execute the js everytime the issue-type /project is changed (exactly like the example script).
And how i can execute the js everytime ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
put the script inside
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e, context) {})
e.g
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function(e, context) {
console.log("new content added")
priority = document.getElementById('priority');
if (priority) {
target = document.getElementById('customfield_12400');
// Hide the target field if priority isn't critical
if (priority.value != 10001) target.style.display='none';
priority.onchange=function() {
if (this.value == 10001) {
target.style.display = '';
target.value="enter message here";
} else {
target.style.display='none';
}
}
}
})
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have to copy all of the code do the description of field ?
Only change customfield id and priority.value ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yes and don't froget the <script type="text/javascript"></script > tags :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello. Does that work on a JIRA server 7.3.3 ? Does it rquires a script-runner plugin or kind-off ? Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It should work on jira server by putting the script in the description of custom field present on that screen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I introduced the code into a field-configuration field description. At issuecreation time, the code is just rendered as plain text. Not interpreted as code. I.E. I can reed the displayed code on the issue pop-up screen. Maybe I must change the main field description as opposed the to field-configuration field description ?
Also, I understood now JIRA would not let JS code inserted in description be ran as code ? So... I am confused.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.