Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Alternative to script inject in Jira v8

Sara Lam
Contributor
May 6, 2020

Hello,

I am looking for a solution to change the default rows of multi select custom field (right now is 5 rows).  Before Jira v8, I was able to use the script below per this document:  https://confluence.atlassian.com/display/JIRA050/How+to+change+Multi+Select+Custom+field+size+using+script?_ga=2.127621583.311521503.1588613064-1990727685.1587148620

<script type="text/javascript">

mselectbox = document.getElementsByName('customfield_10200');

mselectbox[0].setAttribute("size", "20");

</script>

Your help is really appreciated.

Sara Lam

1 answer

0 votes
Lasse Langhorn
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.
May 8, 2020

Hi @Sara Lam

The scripts below will look for for a element with ID 'customfield_10200' and set the size attribute to 20. You might have to change the ID in order to fit the real ID.

Using native Javascripts

<script type="text/javascript">
// Native Javascript
var selectBox = document.getElementById('customfield_10200');
selectBox.setAttribute("size", "20");
</script>

Using JQuery

<script type="text/javascript">
// Using JQuery (built in Jira)
(function ($) {
AJS.$("#customfield_10200").attr("size","20");
})(AJS.$ || jQuery);
</script>

Hope this will work.

Regards

Lasse Langhorn

Sara Lam
Contributor
May 8, 2020

Hi Lasse,

Thank you so much for the suggestion.  Where should I put this script in?  If I put it in the field configuration custom field description area, It seems Jira v8.7 removed the ability to run script there.  Should I put it in banner?  If so, the script will apply to all projects (not project, issuetype specific anymore).  Here is what I got in the field description when I create a ticket:

screenshot1.png

Thanks again,

Sara

Lasse Langhorn
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.
May 8, 2020

Hi @Sara Lam

I would the place the HTML in the Jira banner and yes it will be executed for all Jira projects.

If this is not OK then I will take a look at Behaviours from Scriptrunner which is capable of controlling Jira issue field behaviour.

Regards

Lasse Langhorn

Suggest an answer

Log in or Sign up to answer