Help, how can I write the priority back into the issue from a calculated Scriptrunner customer field

Kay Domschke October 19, 2021

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

1 answer

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 19, 2021
Kay Domschke October 19, 2021

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events