Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,361,978
Community Members
 
Community Events
168
Community Groups

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

Apps for Confluence you won't want to miss: RSVP for September's Appy Hours

Calling all collaborators and Confluence users! Our Appy Hours event on September 29th features 4 presenters demoing functionality to superpower Confluence. Don't miss learning about these apps i...

125 views 0 9
Read article

Atlassian Community Events