Documentation for JIRA 4.4. Documentation for other versions of JIRA is available too.

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

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:
    SELECT id FROM customfield WHERE cfname="Severity";
    
  4. Modify the following javascript code so that <id> will be replaced with the id of the custom field found from the first step:
    <script type="text/javascript" charset="utf-8" id="priorityCustomFieldScript">
        function setIssuePriorityAndSubmit(e)
        {
            // set the value of the priority field here:
    	if(document.getElementById("customfield_<id>_1").checked)
    	{
    		document.getElementById("priority").selectedIndex = 0;
    	}
    	else if(document.getElementById("customfield_<id>_2").checked)
    	{
    		document.getElementById("priority").selectedIndex = 1;
    	}
    	else if(document.getElementById("customfield_<id>_3").checked)
    	{
    		document.getElementById("priority").selectedIndex = 2;
    	}
    	else if(document.getElementById("customfield_<id>_4").checked)
    	{
    		document.getElementById("priority").selectedIndex = 3;
    	}
    	else if(document.getElementById("customfield_<id>_5").checked)
    	{
    		document.getElementById("priority").selectedIndex = 4;
    	}
        }
    
        function hidePriorityAndAddSeverityHook()
        {
    	var row = document.getElementById("priorityFieldArea");
    	row.style.display = 'none';
    
    	AJS.$("#customfield_<id>_1").parents('form').submit(setIssuePriorityAndSubmit);
        }
    
        var currentLocation = window.location.href;
        if (currentLocation.indexOf('CreateIssue') > -1 || currentLocation.indexOf('EditIssue') > -1) {
            AJS.$(document).ready(hidePriorityAndAddSeverityHook);
        }
    </script>
    
  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.

  • ラベルなし