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
Issue Frequency
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 field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.