Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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 Marketplace Apps & Integrations

New Cloud Apps Roundup - April 2021

Atlassian's marketplace partners have had a very productive start to 2021! Since our last roundup, our developer community has added over 160 new cloud apps to the Atlassian Marketplace to help you...

253 views 3 20
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