Forums

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

Conditional Groovy Expression in JMWE post function for multiple options

Edward Basiliere
Contributor
March 30, 2018

Hello,

I am attempting to use a groovy expression as a condition on a transition post function to comment on an issue (JMWE addon). 

The goal is to add a comment to an issue if either option A or B are the value for a specific field. I'm looking to see if this is possible instead of create an additional post function for option "B". The custom field is a single select drop-down.

Here is what I have so far, which works for one value:

return (issue.get("customfield_19100").find { it.getValue() == "A"} != null)

I tried a few different expressions, but none seem to work in that way.

Thanks!

1 answer

1 accepted

1 vote
Answer accepted
David Fischer
Community Champion
March 30, 2018

For single-select custom fields, the test is different, as documented here: https://innovalog.atlassian.net/wiki/spaces/JMWE/pages/107413622/User+created+custom+fields#Usercreatedcustomfields-Radiobuttons/Single-selectlist

Try:

issue.get("customfield_19100") == "A" || issue.get("customfield_19100") == "B"
Edward Basiliere
Contributor
April 2, 2018

Thanks, @David Fischer! Your suggestion seems to be working fine.

SMAtlassianMber
Contributor
July 31, 2019

@David Fischer  

I am trying something very similar with two post functions but I can't get them to work consistently.

Example One Time Cost = 0, Recurring Cost = 10100, goes to done, but should go to the next approval 

Post Function 1 - 

  • Triggers Transition to Done
  • issue.get("One-Time Cost") <= 10000 || issue.get("Recurring Cost") <= 10000  

Post Function 2 -

  • Triggers Transition to next approval CIO
  • issue.get("One-Time Cost") > 10000 || issue.get("Recurring Cost") > 10000  
David Fischer
Community Champion
July 31, 2019

That's because the condition of post-function 1 returns true if One Time Cost = 0. Maybe you meant to write:

issue.get("One-Time Cost") <= 10000 && issue.get("Recurring Cost") <= 10000

which would make more sense as it would then be the opposite of the condition of post-function 2.

SMAtlassianMber
Contributor
July 31, 2019

@David Fischer  That makes perfect sense now that you mention it. What we actual need is the highest of the two fields value to be used.

Suggest an answer

Log in or Sign up to answer