Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JMWE groovy script to set field value based on dropdown

Jemima James June 29, 2022

I have a dropdown field A with the following values:

1 - very low

2 - low

3 - medium

4 - high

5 - very high

I want to set the field B based on the dropdown value.

If A is 1 - very low set B=Green

If A is 2 or 3 set B = Yellow

Else set B = Red

I dont have jira automation. I'm trying to do this using JMWE and regular expressions. But I do not know how to write the groovy expression to get this outcome.

Can someone please help me out?

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1 answer

0 votes
David Fischer
Community Champion
June 29, 2022

Hi @Jemima James 

you can use a Set Field Value post-function, select the field to set (B in your example), select "Groovy Expression" as the value type, and for the value use a script like this:

switch (issue.get("A")) {
case "1 - very low":
return "Green";
case "2 - low":
case "3 - medium":
return "Yellow";
default:
return "Red";
}
Jemima James June 30, 2022

Hi @David Fischer ,

I would like field B to be updated whenever the value changes in field A. Not just on workflow transition.

David Fischer
Community Champion
June 30, 2022

Hi @Jemima James ,

for that, you can put the aforementioned post-function in a JMWE Event-based action that reacts to the Issue Field Value Changed event for field A.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, team ’25 europe guide, teamwork collection, atlassian events, conference guide, team culture, collaboration tools, ai in teamwork, atlassian learning, event schedule, keynote previews, community events

Must attend events for Team Europe '25!

Make the most of your time in Barcelona with our curated guide – discover how Jira, Confluence, Loom, and Rovo work better together, connect with Atlassian experts, and enter to win an Apple prize bundle!

Get the guide
AUG Leaders

Atlassian Community Events