Site announcement

We are switching off article comments on this website. Read about the upcoming changes to Atlassian Documentation.

Documentation for JIRA 6.4 (This documentation includes the project navigation sidebar). Not using this? See below:
(JIRA 6.4 without sidebar documentation | JIRA 6.3.x documentation | JIRA Cloud documentation | earlier versions of JIRA)

Skip to end of metadata
Go to start of metadata

Please note that adding Javascript to custom fields is a customisation and not maintained as a supported part of JIRA.

Please note some of the below items are no longer available from JIRA 6.2.x onwards.

There are several ways to inject JavaScript or HTML into JIRA:

  1. Edit the custom field's description. See Displaying a Field Based on Another Field Selection as an example.
  2. Add JavaScript to the header, by modifying a JSP from the file system. See Adding JavaScript to all pages for Google Analytics as an example.
  3. You can add HTML or Javascript in the Announcement Banner.
  4. Edit the field description in the Field Configuration.

 

  • No labels

14 Comments

  1. #1 and #4 do not work with 6.2 and above. See: JRA-37576

    1. Hi Ron K,

      You are quite correct. We are currently reviewing our FAQs. I've updated this page to reflect it is only valid to JIRA version earlier than 6.2. Apologies for the inconvenience. 

      Thanks,

      Warren

  2. Guys, don't forget to add you comments to ticket  JRA-37576 - Jira 6.2 breaks javascript in description of user-picker fields Resolved  – closing it as Won'tFix will break lots of functionality and flexibility in JIRA. It's normal to assume that JIRA Admins do know what to put inside the field descriptions. Also there are 3rd party plugins that do keep important data there, like iDalko Table Grid one.

    1. Hi Sorin, We have couple of custom fields where some JavaScript code was added to description but now it is not working.  Is there any workaround for this issue? 

  3. Hi, I want to show a field based on value of other field. I am not sure how would I achieve this use case in JIRA 6.2.3. I am using Behaviours plugin in my current version and it is not supported in 6.2.3. Most probably due to the same reason above.

    Please HELP!!!!

  4. Is there a planned fix for this in anything above 6.2? Maybe  6.3?

  5. For me this only seems to be a problem with the single user picker custom field in v6.2.7.

    I have a Javascript in the field description that shows a image and when the image is clicked more description text is shown.

    1. I've solved my issue with 6.2.7 and the Single User Picker custom field.

      Edit
      C:\Program Files\Atlassian\JIRA\atlassian-jira\WEB-INF\classes\templates\plugins\fields\edit\edit-userpicker.vm
      And at the start of the file add
      #disable_html_escaping()
      Javascript rendering now works for me. Thanks goodness.
      (It seems the userpicker vm was missed for this update, all other vms in that directory have that call included)

      1. I have tried on JIRA 6.4 but this is not working for javascript on description of Custom Fields.  Is there any other workaround?

        1. We removed all of our JavaScript from the description of the customfields when we moved from 4.4 to 6.3. We now add the scripts to js files that we add to /includes/js and are loaded from the Announcement Banner. A simple example of the code follows:

          function mycode(){

                          if (AJS.$("#customfield_10000").is('select')){

                          //Only do if the above is present as a select on the form

                                          AJS.$("#assign-to-me-trigger").hide();   //hide the assign to me link

                         

                                          AJS.$('#create-issue-dialog form.aui[name="jiraform"]').bind("before-submit", function (e) {

                                                          alert("Before Create");

                                          }

                                          AJS.$('#edit-issue-dialog form.aui[name="jiraform"]').bind("before-submit", function (e) {

                                                          alert("Before Update");

                                          }

                          }     

          }

          AJS.$(document).bind('dialogContentReady', function(event, dialog) {

                          mycode();          

          });

          Moving the scripts was not easy, but it is much easier to maintain.

          1. Hi Ron, Thanks for your reply. I will try to call the same way as you had suggested and update you.

            1. Hi Ron, The script is not calling on Create Issue screen which opens as dialog box. Have you invoked any script which should act on screens opened on a dialog?

              1. Hi Ron, I got the work around. Now is the script is calling on Create issue dialog. 

  6. Thank you for the solution, Dalectric.