You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
Hello the community,
I try to find a solution on my listener script.
I have two field urgency and impact. I would like to change the priority if one of these fields is updated.
I write the following script but I don't know how to do the update of priority fields.
Could you help me to find the solution?
The script:
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 org.apache.log4j.Level
log.setLevel(Level.DEBUG)
def issue = event.issue as Issue;
def urgency = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("[IMP] Urgency")
def impact = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("[IMP] Impact")
def valueUrgency = issue.getCustomFieldValue(urgency)
def valueImpact = issue.getCustomFieldValue(impact)
log.debug "impact value " + valueImpact;
log.debug "urgency value " + valueUrgency;
if (valueImpact == "High" && valueUrgency == "Medium"){
} else if (valueImpact == "Medium" && valueUrgency == "High"){
} else if (valueImpact == "Medium" && valueUrgency == "Medium"){
} else if (valueImpact == "High" && valueUrgency == "High"){
} else {
}
Thank you a lot for your help.
Regards,
Mickael O.
Can you try this? Set the proper issue key.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.PriorityManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.event.type.EventDispatchOption
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def priorities = ComponentAccessor.getComponent(PriorityManager).priorities
//define the existing priorities (Minor, Major,...)
def majorPriority = priorities.findByName("Major")
def minorPriority = priorities.findByName("Minor")
IssueManager issueManager = ComponentAccessor.issueManager
String issueKey = 'TEST-1'
def issue = issueManager.getIssueObject(issueKey)
issue.setPriorityId(minorPriority.id)
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.