Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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,

Regards

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.
Regards

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")
log.setLevel(Level.DEBUG)

@PluginModule
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
TAGS
Community showcase
Published in Marketplace Apps & Integrations

☕️ Monday coffee with Jexo: Weekly Atlassian news roundup | 21st June 2021

Hi community 👋, as every Monday we're bringing you a quick update on what happened in the Atlassian ecosystem last week. There were a few interesting events like for example the announcement of th...

29 views 0 4
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