Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Published in Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

54 views 0 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you