Automation Email using Old Value and New Value of a field.

Ben Weisman October 25, 2021

Hello,

  I am trying to build an automation that sends an email what the story points on a ticket are updated. I have a smart value set up with the current value in the story point field but is there any way to have the old value in the email as well? Would be helpful to know within the email what it changed from.

Thanks.

4 answers

3 votes
Esther Strom
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 25, 2021

Hi, @Ben Weisman  - yup, just use the fieldChange element. 

2021-10-25 16_42_02-Project automation - Jira - Vivaldi.png

My sample rule is just sending the info to the audit log, but it's the same format in a rule that uses the email action instead.

Documentation here: https://support.atlassian.com/jira-software-cloud/docs/smart-values-general/

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.
October 25, 2021

Hi @Ben Weisman 

Yes, and...to what Esther suggestions:

Just in case the field was empty (or gets cleared), you could add some default handling.  For example, add the pipe symbol followed by a default value of the word EMPTY for the original value:

{{fieldChange.fromString|EMPTY}}

 

Kind regards,
Bill

Like Esther Strom likes this
Alex Shirokov May 29, 2022

Thank you guys for the suggestion. 

 

0 votes
Vicky S April 2, 2024

Hi @Bill Sheboy , I m looking for somewhat similar usecase and i think you should be the right person providing me a solution.

I have a custom date field , I need to use automation which will add a label once any of the member changes the date manually but only for the second time so as to then add the label as Re-Planned , but for all my tries the label is getting added even for the first time when someone selects a date from empty state .(want the label to be added only when its changed second time) Can you please guide me the automation rule here may be using smart values ?  Thanks!

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.
April 2, 2024

Hi @Vicky S -- Welcome to the Atlassian Community!

First thing: this is a older thread, and so I recommend creating a new question, and perhaps linking back to this one.  That will ensure the maximum number of people see it to offer help.

When you create the new question:

  • describe the problem you are trying to solve: the "why do this"
  • include an image of the complete rule
  • include images of any relevant trigger, actions, conditions, and branches
  • include an image of the audit log details showing the rule execution
  • describe what is not working as you expect
  • mention me so I can find the new question :^)

Without seeing your rule, your scenario may need adjustments to the conditions or a "counter field" to track the changes.  The specifics will depend on your rule and field.

Thanks, and kind Regards,
Bill

0 votes
Troy March 29, 2023

HI @Bill Sheboy I am in a company-managed JIRA project.

The custom field "NBIT Release” is having type= Select List (Single Choice)

I tested the rule with a dummy ticket, so when I selected current value as Release 3, got the below result

current value: [Release 3]
length of the value:

and when I cleared the field like image.png then got the below result

current value: []
length of the value:

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.
March 29, 2023

Hi @Troy 

Sorry this thread is splitting/scattering.  This is one of the reasons why it is better to create your own question and link back to other, related ones: less chance of other questions getting asked in the middle of the discussion  :^)

Okay, it appears to me that {{changelog}} is one of those smart values which appears to be dynamically populated, and so doesn't work with all the functions of rules.  That makes sense as it is probably filled in just-in-time from the issue history.

So the work-around for this use case is to capture the {{fromString}} first and then use it.  For example:

  • action: create variable to save the previous value, which will force it to text type
    • variable name: varPreviousValue
    • Smart value: {{#changelog.Release}}{{fromString}}{{/}}
  • use the result, such as in your email
    • {{#if(varPreviousValue.length().lte(0))}}None{{/}}{{varPreviousValue}}

This will return either None or your previous value.  Please try that to see how it helps.

Like Troy likes this
Troy March 30, 2023

Hey @Bill Sheboy thanks for that create variable pointer, working like a charm now :)

I created one more variable to store the current value as well and used the below in my email body:

Previous value: {{#if(varPreviousValue.length().lte(0))}}None{{/}}{{varPreviousValue}}
Current Value: {{#if(varCurrentValue.length().lte(0))}}None{{/}}{{varCurrentValue}}

many thanks for your support mate 👍

Like Bill Sheboy likes this
Troy June 11, 2023

Hi @Bill Sheboy hope you are well.

Please can you check my query here How do I display previous value of Fix versions fi... (atlassian.com) ? I am hoping you can provide a solution like last time :) Thanks!

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.
June 11, 2023

Hi @Troy 

I responded to you in the other thread. 

Short version for other readers: this is broken and appears to be a known defect which also appears to have a low priority/likelihood of being fixed soon.

Kind regards,
Bill

Like Troy likes this
0 votes
Troy March 26, 2023

Hope everyone having a nice Sunday.

@Ben Weisman thanks for posting this query as this is exactly what I was looking for :)

Thanks for the solution @Esther Strom & @Bill Sheboy 

I am using the Send Email trigger and in my email content I have kept as below

Previous value: {{#changelog.Release}}{{fromString|EMPTY}}{{/}}
Current value: {{#changelog.Release}}{{toString|EMPTY}}{{/}}

It is working all fine except when the Release field is cleared, the email content reads as

Previous value: Release 1
Current value:

Is there a way to display None as opposed to blank when the Release field is cleared?

Thanks,

Troy

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.
March 26, 2023

Hi Troy, and welcome to the Atlassian Community!

You may be able to do that with the rule conditional logic.  However there is no "Send Email Trigger", although there is an action for that, and so...

Please post images of your complete rule and the audit log details.  Those will provided context for the community to offer ideas.

Kind regards,
Bill

Like Troy likes this
Troy March 28, 2023

Thanks for your response, Bill.
Please see screenshots below for the complete rule and email action, nothing on the audit log to share :)

 1.png2.png

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.
March 28, 2023

Thanks for that information.  As the current value is the one not working, perhaps just use the current value and conditional logic, like this:

Current value: {{issue.NBIP Release}}{{#if(issue.NBIP Release.isEmpty)}}None{{/}}

Both parts appear to be needed when a field has ever contained a value, as it will not be null for default handling in the future.

Troy March 28, 2023

Thanks Bill, I made that changes in the Email content as below

Previous value: {{#changelog.NBIT Release}}{{fromString|EMPTY}}{{/}}
Current value: {{issue.NBIT Release}}{{#if(issue.NBIT Release.isEmpty)}}None{{/}}

But still don't manage to print None against Current value

Previous value: Release 3
Current value:

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.
March 28, 2023

What is the type of your project: company-managed or team-managed?  You may find that at the bottom of the left-side expand panel on the page.

What is the type of that custom field: text, single-select option, etc.?

Knowing that information may help explain what you are observing, as that field appears to contain something which is not empty.

Another thing to test that is to write the following to the audit log:

current value: [{{issue.NBIT Release}}]
length of the value: {{issue.NBIT Release.length()}}

 The first one will show what is in the field, surrounded by brackets.  If it is not truly empty, something will appear.

The second will be the length of the field, if it is a text field.

Alan March 28, 2023

Hi @Bill Sheboy

I just stumbled upon this thread and am going through the same issue, but with the Target End Date field (custom field provided by Advanced Plan/Portfolio). 

Using {{fieldChange.toString}}{{#if(issue.Target End.isEmpty)}}None{{/}}, I am also not getting "None" but an empty value. I added the suggested test values to the audit log and got:

current value: []
length of the value:

So, it appears the value is empty but the conditional logic is still getting skipped.

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.
March 28, 2023

Hi Alan, and welcome to the Atlassian Community!

Many of the advanced roadmap fields are not supported by the built-in automation actions yet.  Instead you must use JSON to access them, as described in this suggestion: https://jira.atlassian.com/browse/JIRAAUTOSERVER-159

A few things to investigate...

(1) First, smart values are name, spacing, and case-sensitive.  So please try this how-to article to confirm you have the correct values: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

(2) Next, I wonder if those fields are supported by the fieldChange and changelog values.  You may need to test those individually first by writing to the audit log, such as with: {{#changelog.Target End}}{{fromString}}{{/}}

(3) Finally, when you narrow the scope of a smart value expression, such as within the {{fieldChange}} expression, the {{issue}} smart values are no longer visible.  So if the smart values are visible in automation, I would try just the current value first, with a single conditional on that value; don't bother looking at {{toString}}

Kind regards,
Bill

Suggest an answer

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

Atlassian Community Events