JMWE Conditional Execution

Ash
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 23, 2020

Hi Community,

 

I'm trying to use conditional execution in JMWE addon.

 

Below is the condition I'm trying on two text fields. If there is a word approved or deferred text in the field i need to execute this condition.

 

No luck with the below condition.

{{ issue.get("customfield_14802") == /.*Approved.*/ or issue.get("customfield_14802") == /.*Deferred.*/ }}

 

TIA!

 

1 answer

1 accepted

0 votes
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 23, 2020

Hi @Ash , you seem to want to use regular expressions in your test. In Groovy, the regex matcher operators are =~ (substring match) and ==~ (exact match). So you can try:

issue.get("customfield_14802") ==~ /.*Approved.*/ || issue.get("customfield_14802") ==~ /.*Deferred.*/

although that will also match "DisApproved" (because you didn't use a word begin/end pattern (\b) and won't match "approved" because you didn't use case-insensitive matching with (?i).

A better test would be:

issue.get("customfield_14802") =~ /(?i)\b(approved|deferred)\b/ 
Ash
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 24, 2020

Thank you @David Fischer . Appreciate your help as always.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events