Fields Allowing Custom HTML or JavaScript

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.

Was this helpful?

Thanks for your feedback!

14 Archived comments

  1. User avatar

    Ron K

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

    25 Apr 2014
    1. User avatar

      Warren Thompson

      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

      28 Apr 2014
  2. User avatar

    Sorin Sbarnea

    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.

    28 Apr 2014
    1. User avatar

      srinivas patruni

      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? 

      17 Apr 2015
  3. User avatar

    Sunny Goyal

    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!!!!

    01 May 2014
  4. User avatar

    Adam White

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

    06 Jun 2014
  5. User avatar

    Dalectric

    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.

    17 Jul 2014
    1. User avatar

      Dalectric

      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)

      31 Jul 2014
      1. User avatar

        srinivas patruni

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

        17 Apr 2015
        1. User avatar

          Ron K

          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.

          17 Apr 2015
          1. User avatar

            srinivas patruni

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

            17 Apr 2015
            1. User avatar

              srinivas patruni

              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?

              17 Apr 2015
              1. User avatar

                srinivas patruni

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

                17 Apr 2015
  6. User avatar

    Jacob Gilley

    Thank you for the solution, Dalectric.

    10 Dec 2014
Powered by Confluence and Scroll Viewport