Problem with JavaScript in description field

Hi,

I am facing a problem using Javascript in the description field. As soon as I change the issue type (issue creation screen) the scripts are being ignored.

Example 1: Replacing the "None" option in select field

<script type="text/javascript">try
{var select = document.getElementById('customfield_10071');select.options[0].text="";}
</script>

The code above is in a field description associated with a project and an issue type. If I create an issue and the issue is the first to pop up in the issue type list (e.g. the most recent to have been created) the scripts fire. If I select another issue type with other scripts in their field descriptions those are being ignored...

Example 2: Hiding the Assign to me link

&lt;script type="text/javascript"&gt;   
AJS.$("#assign-to-me-trigger").hide()     
&lt;/script&gt;

Any of you has experienced this behaviour?

Thanks in advance

Christian

2 answers

1 accepted

Found a solution. Fixed the none option problem in the VM-file (issue has been fixed by Atlassian aswell) and edited my JS to sth. like this

&lt;script type="text/javascript"&gt;
jQuery(document).ready(function($) {
 XX();
  JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) { XX(); });
});

function XX()
&lt;/script&gt;

you need to add javascript file using webresource module in plugin insted of adding in description

find thesample webresource module below

&lt;web-resource key="test-js" name="javascript"&gt;
        &lt;dependency&gt;jira.webresources:global-static&lt;/dependency&gt;
        &lt;description&gt;JavaScript&lt;/description&gt;
        &lt;resource name="test.js" type="download" location="templates/js/test.js" /&gt;
        &lt;context&gt;atl.general&lt;/context&gt;        
   &lt;/web-resource&gt;

test.js file like

JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) {
AJS.$("#assign-to-me-trigger").hide()  
});

Hey, I'll try that. Thank you in advance...

Hey rambanam, one question, why does the javascript, if I use it in the field description, just fire once?

Cheers Christian

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,187 views 13 19
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot