Documentation for JIRA 6.3 EAP developer (EAP) releases only. Not using this? See below:
(JIRA 6.2.x documentation | JIRA OnDemand documentation | earlier versions of JIRA)

Skip to end of metadata
Go to start of metadata

Icon

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

Icon

Check the comments below. This page has been flagged as outdated.

 

As the users are neglecting the description of the Priority field, a more detail custom field is created to represent the Priority field. Depending on the radio button custom field selected, the Priority field value is set.

  1. Create a customfield name "Severity" at Browse >> Administration >> Issue Fields >> Custom Fields
  2. Configure the radio button custom field to have a field options
  3. Check the customfield ID in the Customfield table from the database by using the following SQL query:

  4. Modify the following javascript code so that <id>will be replaced with the id of the custom field found from the first step:

  5. Paste the javascript into the description of the "Severity" customfield at Browse >> Administration >> Issue Fields >> Custom Fields.

There is no need to hide or remove the 'Priority' field from the screen. The javascript code will hide the Priority field by itself.

  • No labels

9 Comments

  1. Anonymous

    On Jira 4.2, the naming of the customfield contains a '-' instead of a '_' in the end. The following snippet is working here with customfield id = 10133:

    Regards,

    Tom Moors [ACA IT-Solutions]

  2. Anonymous

  3. Anonymous

    I have attempted to do this in Jira 4.3 although it is not working. The priority field is not being hidden and the priority is not being changed accordingly once the issue has been submitted. Is there anything else which I need to change or can I just chuck this code into any radio button field once I have modified in my ID?

    Here is my code once modified. The ID for my "Severity" field is 10527.

    1. Is this code will work for select list field ???

  4. Anonymous

    I have tried implementing this example in 4.3. with the customfield containing a '-' instead of a '_' in the end, but it is not working. Any recommendations?

    Thanks,

    Velina Urdova

  5. This article is a bit out-of-date and should be updated. Also, it seems SAC implements this solution differenty, and arguably, in an easier way.

    1. You don't need to create a seperate custom field. First, go the the Field Configuration for the project and Edit the Description of the Priority field with:

     

    2.  Make sure the Priority is visible on the Create Issue screen for your project.

    3. You're done. (smile)

  6. Hi Justin,

    I've tried this code and its working only at create screen, after putting the value in "Severity of Problem" field its been not reflecting in view screen. There showing same priority field with common values. Please suggest?

    Many thanks in advance.

    Sanu P Soman

  7. hey I tried using this code in the description, but it doesnt work for me? I am using JIRA 4.1.2 can anyone suggest if JIRA 4.1.2 supports this? Thanks

    <script type="text/javascript" charset="utf-8" id="priorityCustomFieldScript">   
    function setIssuePriorityAndSubmit(e)   
    {       
    // set the value of the priority field here:   
    if(document.getElementById("customfield_10111-1").checked)   
     {        document.getElementById("priority").selectedIndex = 0; 

       }
    }

    function hidePriorityAndAddSeverityHook()   
    {    var row = document.getElementById("priorityFieldArea");   
    row.style.display = 'none';    

    AJS.$("#customfield_10111-1").parents('form').submit(setIssuePriorityAndSubmit);   
    }    

    var currentLocation = window.location.href;   
    if (currentLocation.indexOf('CreateIssue') > -1 || currentLocation.indexOf('EditIssue') > -1) {     

      AJS.$(document).ready(hidePriorityAndAddSeverityHook);   
    }</script>

  8. Is there a way to do something similar to this in on demand?

    Maybe using post functions in the workflow. If a custom field is set to "Site down" then priority is set yo "Urgent"