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

How I Can update System Priority Fields from to two another custom fields

Hi Community,

I want to set Priority field from two another custom field directly on creation screen.

To set the priority, I want to use a combinaison of repeatability value and severity value.

I try to had Post-function with jMWE plugin with no result.

with this groovy expression in Value box

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def repeat=customFieldManager.getCustomFieldObjects(issue)?.find { it.id == "customfield_17394"}
def severity=customFieldManager.getCustomFieldObjects(issue)?.find { it.id == "customfield_17393"}
def repeatVal=issue.getCustomFieldValue(repeat)
def severityVal=issue.getCustomFieldValue(severity)
def highest="10303"
def high="10300"
def low="10302"
def lowest="10301"

if (repeatVal == "Non identifié" && severityVal == "Bloquant" ){
issue.setPriorityId(highest)
}

if (repeatVal == "Non identifié" && severityVal == "Critique" ){
issue.setPriorityId(highest)
}

if (repeatVal == "Non identifié" && severityVal == "Majeur" ){
issue.setPriorityId(highest)
}

if (repeatVal == "Reproductible" && severityVal == "Bloquant" ){
issue.setPriorityId(highest)
}

if (repeatVal == "Intermittent" && severityVal == "Bloquant" ){
issue.setPriorityId(highest)
}

if (repeatVal == "Non identifié" && severityVal == "Mineur" ){
issue.setPriorityId(high)
}

if (repeatVal == "Reproductible" && severityVal == "Majeur" ){
issue.setPriorityId(high)
}

if (repeatVal == "Intermittent" && severityVal == "Critique" ){
issue.setPriorityId(high)
}

if (repeatVal == "Unique" && severityVal == "Bloquant" ){
issue.setPriorityId(high)
}

if (repeatVal == "Reproductible" && severityVal == "Mineur" ){
issue.setPriorityId(low)
}

if (repeatVal == "Intermittent" && severityVal == "Majeur" ){
issue.setPriorityId(low)
}

if (repeatVal == "Unique" && severityVal == "Critique" ){
issue.setPriorityId(low)
}

if (repeatVal == "Intermittent" && severityVal == "Critique" ){
issue.setPriorityId(lowest)
}

if (repeatVal == "Unique" && severityVal == "Majeur" ){
issue.setPriorityId(lowest)
}

Anyone can help me ?

1 answer

0 votes

Hi @Christophe ARON ,

since you're using JMWE, there's actually a must easier way to achieve this. All you need is a Set Field Value post-function with the following settings:

- Field: Priority

- Value type: Groovy Expression

- Value: something along the lines of the following Groovy script:

def repeatVal = issue.getAsString("customfield_17394")
def severityVal = issue.getAsString("customfield_17393")


def highest="10303"
def high="10300"
def low="10302"
def lowest="10301"

switch(repeatVal) {
case "Non identifié":
switch(severityVal) {
case "Bloquant": return highest
case "Critique": return highest
 case "Majeur": return highest
  case "Mineur": return high
default: return low
}
case "Reproductible":
switch(severityVal) {
case "Bloquant": return highest
case "Critique": return highest
  case "Majeur": return high
   case "Mineur": return low
default: return low
}
//etc for the other values for repeatVal
}

This approach makes the code much more readable, and avoids forgetting some combinations (as you did in your code - e.g. Reproductible + Critique)

Hi David,

 

Thanks for your reply, when I reading again documentation I saw that I'm going wrong.

You're code is more clearly and easy.

Thanks, this approach work well!

That's solved my problem.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

How we use Jira Service Management for our recruitment process! - Part 2

It is never about setting up a process and being done with it. Rather, the focus should always be on optimizing it for the best outcomes. Thus, we didn’t stop at setting up JSM for our recruitment pr...

194 views 0 5
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