Forums

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

Trouble with Match in Jira Global Automation

Wayne Bryan
Contributor
September 11, 2024

I'm creating a variable in Global Automation  "PriorityUp" 

When: Value changes for Priority 

 

{{#if ( and( exists(fieldChange.toString.match("P[0-5]")), not(exists(fieldChange.fromString.match("P[0-5]"))) ) ) }}UP{{/}}

 

The intent if new priority value is in P0,P1,P2,P3,P4,P5 

and the old value is not in P0,P1,P2,P3,P4,P5 (for example if it was "2 - Critical" 

then the variable would be set to UP

 

using log statements these have string values as I would expect  

fieldChange.toString = ""P1"

fieldChange.fromString = "2 - Critical"

ChangeItemBean{fieldId='priority', field='priority', fieldType='null', from='11305', fromString='2 - Critical', to='10302', toString='P1'};

 

But these don't work, return null?  

fieldChange.toString.match("P[0-5]"  

fieldChange.fromString.match("P[0-5]") 

 

what is the trick needed to make the match function work? 

1 answer

0 votes
Bill Sheboy
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.
September 11, 2024

Hi @Wayne Bryan 

For an automation question like this, context is important...

Please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected. Those will provide context for the community to offer ideas. Thanks!

Until we see those...

Is your {{#if()}} ... {{/}} expression inside of an iterator or issue-scoped, smart value expression?  If so, the change log smart values will not be visible.

Next, some smart values do not work inside of functions.  (I do not know the reason for this.)  As you have already tested to confirm the toString and fromString values can be written to the audit log, a workaround could be to first save those with the Create Variable action, and then use the variables in your condition tests.

Again, seeing your rule will help confirm what is possible.

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events