Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Priority field that can be automatically populated based on other 2 fields Severity and Frequency

Hi All,

I would like to automatically change the priority field based on the combination of information from the Severity and Frequency fields?  

For example if Issue Severity is "1-High" and Issue Frequency is "2 -Medium" , the priority would be "Major".  I am new to groovy script. can anyone help me this how to write it in grrovy script ? 

Issue Severity 

  • 1 - Critical
  • 2 - High
  • 3 - Medium
  • 4 - Low

Issue Frequency

  • 1 - High
  • 2 - Medium
  • 3 - Low
  • 4 - Rare

1 answer

Hi Lakshimi S,

I created some time ago an example of a scripted field (see priorityMatrix.groovy) that can serve as a base for what are you triying to achieve.


In your case you will create either a postfunction or a script listener and setup the issue priority instead of returning a value.


Hope this helps,


Thank you so much for your quick reply @Jack Nolddor _Sweet Bananas_  , here the "priority" field is system field, not a text fieldsys field.PNG

I know, you must use my script as a base to make yours.

You should use issue.setPriorityId() method instead of returning a value as in mine.

Hi @Jack Nolddor _Sweet Bananas_ ,

  Its not working. Can you please help me on this ?



import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.priority.Priority
import com.atlassian.jira.issue.CustomFieldManager

def log = Logger.getLogger("com.nolddor")

CustomFieldManager customFieldManager

// You must change the following variables as your needs
def severityFieldName = "Issue severity"
def frequencyFieldName = "Issue Frequency"

def matrix = [
[issueseverity: '1 - Critical', issuefrequency: '1 - High', priority: 'Major'],
[issueseverity: '3 - Medium', issuefrequency: '3 - Low', issuepriority: 'Trivial'],

//Retrieve customfields from the system
def severityField = customFieldManager.getCustomFieldObjectsByName("severityFieldName").find()
def frequencyField = customFieldManager.getCustomFieldObjectsByName("frequencyFieldName").find()

// Ensure source fields really exist
if(severityField && frequencyField)
// Retrieve customfield values as String
//def impact = issue.getCustomFieldValue(impactField).toString()
//def urgency = issue.getCustomFieldValue(urgencyField).toString()

def severity = issue.getCustomFieldValue(severityField)
def frequency = issue.getCustomFieldValue(frequencyField)

// Check for any match on our matrix
def row = matrix.find {row -> row.issueseverity == severity && row.issuefrequency == frequency}
// Return the priority for the matching row (if any)

return issue.setPriorityId(3)

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events