Setting Priority field value based on customfield value in 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.

 

Another method is to change this at the create screen without a customfield:

  1. First, go the the Field Configuration for the project and Edit the Description of the Priority field with:
<div id='PriorityHelpMessage'>
    <UL>
        <LI><strong>Level 1</strong> - Production application down or major malfunction resulting in majority of users unable to perform their normal functions. (Expected response time = 1 hour)</LI>
        <LI><strong>Level 2</strong> - Critical loss of application functionality or performance resulting in high number of users unable to perform their normal functions. (Expected response time = 4 hours)</LI>
        <LI><strong>Level 3</strong> - Moderate loss of application functionality or performance resulting in multiple users impacted in their normal functions. (Expected response time = 8 hours)</LI>
        <LI><strong>Level 4</strong> - Minor loss of application functionality or product feature question. (Expected response time = 24 hours)</LI>
    </UL>
</div>
<script type="text/javascript">
    AJS.$(document).ready(function() {
        if(window.location.href.indexOf('CreateIssue') > -1)
        {
            var parent = AJS.$("#priority").parents('.field-group');
            parent.removeClass('field-group');
            parent.addClass('group');
            parent.html("<legend><span>Severity of Problem <span class='aui-icon icon-required'></span><span class='content'>Required</span></span></legend>"+
            "<div    class='radio'>"+
                    "<input class='radio' id='Level1' name='priority' type='radio' value='2'>"+
                    "<label for='Level1'>Production application down or major malfunction resulting in majority of users unable to perform their normal functions. (Expected response time = 1 hour)</label>"+
                "</div>"+
                "<div class='radio'>"+
                    "<input class='radio' id='Level2' name='priority' type='radio' value='3'>"+
                    "<label for='Level2'>Critical loss of application functionality or performance resulting in high number of users unable to perform their normal functions. (Expected response time = 4 hours)</label>"+
                "</div>"+
                "<div class='radio'>"+
                    "<input class='radio' id='Level3' name='priority' type='radio' value='4'>"+
                    "<label for='Level3'>Moderate loss of application functionality or performance resulting in multiple users impacted in their normal functions. (Expected response time = 8 hours)</label>"+
                "</div>"+
                "<div class='radio'>"+
                    "<input class='radio' id='Level4' name='priority' type='radio' value='5'>"+
                    "<label for='Level4'>Minor loss of application functionality or product feature question. (Expected response time = 24 hours)</label>"+
                "</div>"+
                "<div class='description'>"+
                    "<img src='/download/resources/com.atlassian.jira.plugins.support-resources:web/support/images/info.png'/>&nbsp;For more information on support levels of severity please visit this <a href='http://confluence.atlassian.com/x/uAGVCw' target='_blank'>guide</a></img>"+
                "</div>"
            );
        }
        else if(window.location.href.indexOf('EditIssue') == -1)
        {
            AJS.$("#PriorityHelpMessage").hide();
        }
    });
</script>

 

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

3. You’re done.

Advertisements

4 thoughts on “Setting Priority field value based on customfield value in JIRA

  1. So your users are neglecting (or maybe confused) by the choices in the Priority field. My first approach would be to change the choices. I’ve also used JavaScript to provide fold-out text with more information that a usual terse description. But in the end I suspect it’s because the Priority field is used for different things by different groups of people. E.g. Support Priority, Engineering Priority, QA priority. You could try adding a custom field for each kind of priority and then have a PM responsible for setting the overall Priority field.

    • Almost correct! A lot of our users are staff members who are in sales, finance etc. and aren’t overly technologically minded. The way we work currently is that we set priority based on severity, and then we use issue types to assist in issue categorisation. For now, we are putting the default priority as minor, and having the PM (me in this case) assign the correct priority and issue type for the ticket.

      Once we move to JIRA 6 (should be in a couple of weeks hopefully), I will introduce more things such as automatic escalation and time based resolutions, more custom fields, and work with our staff to find out the best way to assign the priority and/or issue type.

      The Javascript fold-out certainly seems like a fantastic idea, and certainly one I’ll be looking at integrating, as it should really help out our staff (both IT and otherwise)!

      • I know people get detailed about what severity means, but I usually end up calling that field “Engineering Priority” or “Customer Priority” or such.

        Anyway here’s the guts of the foldout help text in case it’s any use:

        function showHelp() {
        var helpDiv = AJS.$(“#severityFieldHelp”);
        if (helpDiv.length == 1) {
        helpDiv = helpDiv[0];
        if (helpDiv.style.display == ‘none’) {
        helpDiv.style.display = ”;
        } else {
        helpDiv.style.display=’none’;
        }
        }
        }

        The impact of the problem for the customer.

        Sev 1 SLA 24 hour response time required
        Text here
        More text here
        Sev 2 SLA 48 hour response time required
        Text here.
        More text here.

      • Ah, now that is truly fantastic!

        I will have a look at implementing that tomorrow on at least our development JIRA.

        We are basically using the Issue Type as the Severity field in our case, and priority as the Severity (as I didn’t know that you could enable the severity field until recently!).

        Thanks! :)

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s