Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

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

1 answer

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
Community showcase
Published in Apps & Integrations

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