cancel
Showing results for
Did you mean:
See all
Top groups
Explore all groups
Support
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating. Help, how can I write the priority back into the issue from a calculated Scriptrunner customer field

Edited

I can easily determine the required values from several fields. If I have all the values, then I can also define the new priority of the issue. Unfortunately I don't manage to write them back. Appreciating any clues.

def Leben = getCustomFieldValue("Leben")
def Notfall = getCustomFieldValue("Notfall")
def GS = getCustomFieldValue("GS")
def DS = getCustomFieldValue("DS")
def SK = getCustomFieldValue("SK")

int result = 0
int Prio = 10505

if (Leben.value == "Ja" || Leben.value == "Offen") {
result = 4
}
else {
if (Notfall.value == "Ja") {result = 2}
if (GS.value == "Ja" || GS.value == "Offen") {result = result +1}
if (DS.value == "Ja" || DS.value == "Ohne") {result = result +1}
}

// Priorität MEDIUM
if (SK.value == "Sehr hoch" && (result == 1 || result == 0)) {Prio = 10400}
if (( SK.value == "Mittel" || SK.value == "Hoch") && result == 1) {Prio = 10400}
if ((SK.value == "Sehr niedrig" || SK.value == "Mittel") && result == 2) {Prio = 10400}
if (SK.value == "Sehr niedrig" && result == 3) {Prio = 10400}

// Priorität High
if ((SK.value == "Sehr hoch" || SK.value == "Hoch") && result == 2) {Prio = 10504}
if ((SK.value == "Mittel" || SK.value == "Hoch") && result == 3) {Prio = 10504}
if ((SK.value == "Sehr niedrig" || SK.value == "Mittel") && result == 4) {Prio = 10504}

// Priorität Highest
if (SK.value == "Sehr hoch" && result == 3) {Prio = 10701}
if ((SK.value == "Sehr hoch" || SK.value == "Hoch") && result == 4) {Prio = 10701}

// Here I'm not able to write back the Priority ID.

return result

Thanks for the hint. What is my fault. No errors, no result?

import com.atlassian.jira.component.ComponentAccessor
def issueService = ComponentAccessor.issueService

def Leben = getCustomFieldValue("Leben")
def Notfall = getCustomFieldValue("Notfall")
def GS = getCustomFieldValue("GS")
def DS = getCustomFieldValue("DS")
def SK = getCustomFieldValue("SK")

int result = 0
int Prio = 10505

if (Leben.value == "Ja" || Leben.value == "Offen") {
result = 4
}
else {
if (Notfall.value == "Ja") {result = 2}
if (GS.value == "Ja" || GS.value == "Offen") {result = result +1}
if (DS.value == "Ja" || DS.value == "Ohne") {result = result +1}
}

// Priorität MEDIUM
if (SK.value == "Sehr hoch" && (result == 1 || result == 0)) {Prio = 10400}
if (( SK.value == "Mittel" || SK.value == "Hoch") && result == 1) {Prio = 10400}
if ((SK.value == "Sehr niedrig" || SK.value == "Mittel") && result == 2) {Prio = 10400}
if (SK.value == "Sehr niedrig" && result == 3) {Prio = 10400}

// Priorität High
if ((SK.value == "Sehr hoch" || SK.value == "Hoch") && result == 2) {Prio = 10504}
if ((SK.value == "Mittel" || SK.value == "Hoch") && result == 3) {Prio = 10504}
if ((SK.value == "Sehr niedrig" || SK.value == "Mittel") && result == 4) {Prio = 10504}

// Priorität Highest
if (SK.value == "Sehr hoch" && result == 3) {Prio = 10701}
if ((SK.value == "Sehr hoch" || SK.value == "Hoch") && result == 4) {Prio = 10701}

def issueInputParams = issueService.newIssueInputParameters()
issueInputParams.with {priorityId = Prio}

return result

TAGS
Community showcase

Marketplace Partner Spotlight: Fine Software

Happy New Year, everybody! What better way to kick off 2022 than with a new Marketplace Partner Spotlight ✨ This month, we're getting to know Daniel Franz, co-founder of Fine Software. Fine Software ...

369 views 2 15

Community Events

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

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

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