Setting Priority field value based on customfield value
Please note that adding Javascript to custom fields is a customisation and not maintained as a supported part of JIRA.
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.
- Create a customfield name "Severity" at
Browse >> Administration >> Issue Fields >> Custom Fields
- Configure the radio button custom field to have a field options
Check the customfield ID in the Customfield table from the database by using the following SQL query:
SELECT id FROM customfield WHERE cfname="Severity";
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>
- 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.