using new and previous custom field values in an automation

Michael Nassette
Contributor
August 2, 2024

Hi,

I want to execute an automation action based on a custom field value change.
What I have set up now:
Trigger:
When: Value changes for "Field A"

IF
{{issue.Field A.fieldChange.fromString}} equals X
AND
{{issue.Field A.fieldChange.toString}} equals Y
THEN: Edit issue fields "Field B"

When I edit Field A from X to Y, I expect an action to be executed on Field B.

This action is not happening, when checking the audit log I am getting a "No actions performed" with a "The following issues did not match the condition:".

I do not understand where I am going wrong, though expect it to be something extremely obvious (yet not to me).
Anybody has any suggestions?

3 answers

1 accepted

4 votes
Answer accepted
Michael Nassette
Contributor
August 2, 2024

So what I settled on is :

{{#changelog.Field A}}{{fromString}}{{/changelog.Field A}} equals X
AND
{{#changelog.Field A}}{{toString}}{{/changelog.Field A}} equals Y

This is where the plot thickens, and I probably have not been asking the right questions.
Field A has 6 available value, all starting with a numerical value going from 1 to 6.

The difference between the first numeric value of X and Y needs to get added to the current value of Field B.

I think it should be possible to do in 1 line of code (big question mark), but I have clearly bitten off here more than I can chew. I think I understand the logic of how the line should look like, I just can not find out the correct syntax.
What I am thinking about is the following:

{#math}}
{{currentvalue.Field B}}
+
( {{oldvalue.Field A.charAt(0)}} - {{newvalue.Field A.charAt(0)}} )
{{/}}

 Would it be possible at all to use old field values and character stripping in a math formula?

Michael Nassette
Contributor
August 2, 2024

Sorry for whiteboarding here, but I found the solution

When the field value changes, first I create 2 new variables

{{oldvalue}} = {{#changelog.Field A}}{{fromString}}{{/changelog.Field A}}

{{newvalue}} = {{#changelog.Field A}}{{toString}}{{/changelog.Field A}}

Next I used a THEN component to edit Field B with the following:

{{#math}}{{issue.Field B}} + {{oldvalue.charAt(0)}} - {{newvalue.charAt(0)}}{{/}}

 

This does exactly what I need it to do, maybe there is a better way of doing it still, but for now this is sufficient.

Like Laurie Sciutti likes this
1 vote
Boris Zozoulia
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.
August 2, 2024

As per doco, @Michael Nassette  

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--eventType--

 

The field change trigger exposes {{fieldChange}}variable, which would have the previous and new value for the field in trigger.

So, remove issue.FieldA part in your if condition, and it should work fine

Boris Zozoulia
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.
August 2, 2024

Or, at least I assume so, it should work...

0 votes
Anandhi Arumugam _Cprime_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 2, 2024

Hi @Michael Nassette Could you try something like the following condition based on Smart values?

Advanced Compare condition

Field value = {{#changelog.Field A}}{{fromString}}{{/Field A}} equals X

Field value = {{#changelog.Field B}}{{toString}}{{/Field B}} equals Y

Hope this helps!

Suggest an answer

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

Atlassian Community Events