JavaScript on Custom Field Description of JIRA 6.4

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 14, 2015

Custom JS existing on description of custom field is simply showing as description on screens. Existing functionality was broken on Create Issue screens. Is there any workaround?

2 answers

1 vote
srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2015

Remove JS from description and copy it as a JS file. Now call the custom JS file from announcement banner. it works.

Kai Gottschalk
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 19, 2015

Good approach. Exactly the same we did already since a few years and hence it - luckily - saved us during the update to JIRA 6.4.11 :-)

gangadhar pulipelli June 16, 2017

hi @srinivas

Looks like a promising solution. Can you please post an example of how I can call teh custom JS from announment banner?

I have the sample script here, which change sthe value of one custom field depending on other field's value. This once doesn't worked when the JS placed in Description.

"<script type="text/javascript">
appName = document.getElementById('customfield_14262');

target = document.getElementById('customfield_14261');


if (appName=="Bergen.Service) {
target.value = "bergen  service"

}
</script>"

 

 

0 votes
Boris Berenberg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 14, 2015

We disabled this on purpose: https://confluence.atlassian.com/display/JIRA/Fields+Allowing+Custom+HTML+or+JavaScript You can use a plugin to deliver custom JS if you need to. 

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 14, 2015

Looks like the website was down so I am not sure what it was on the mentioned page. Can we enable this again? One question: Cant we use JS on any existing JSP pages or on Announcement Banner?

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 16, 2015

Boris, I tried many times but the site is down. Could you please point any other page if that was available?

Boris Berenberg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 16, 2015

The site is not down, I just tested it. I would suggest trying to access it from a different connection? Or maybe something is busted with your Atlassian ID account, try viewing it in an incognito window.

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2015

Hi Boris, I am able to access the site on different browser. Could you please provide some more details about plugin to deliver custom JS?

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2015

We have custom JS on some of description fields, actually copies reporter user field value to some custom fields. Could you please suggest any workaround to achieve this functionality?

Boris Berenberg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2015

You would need to write a standard P2 (not connect) JIRA plugin to inject Javascript. I am not familiar with the exact how to for this as I am not a dev, but I know this is how we deliver custom JS on some of our instances. The only workaround I have is to do this via post functions where you can, and write a custom plugin to inject JS where you can't.

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2015

Post functions does not help us since we need to call the JS on page load of Issue Create.

Boris Berenberg
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2015

This is what you would use to load JS: https://developer.atlassian.com/jiradev/jira-architecture/building-jira-add-ons/jira-plugins2-overview/jira-plugin-module-types/web-resource-plugin-module Some Googling around says https://marketplace.atlassian.com/plugins/de.communardo.atlassian.plugins.cute may also do this, but I don't know for sure. Would be important to trial and test first to see if it can help you inject the JS where you need.

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2015

Hi Boris, I got a simple work around. Now custom JS is also calling from announcement banner. I was not able to call JS on Create Issue dialog with the earlier versions from announcement banner but on JIRA 6.4 it is working. Thanks for sharing the links.

Suggest an answer

Log in or Sign up to answer