Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,560,472
Community Members
 
Community Events
185
Community Groups

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

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.

3 answers

2 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.
Oct 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.
Oct 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

Thank you guys for the suggestion. 

 

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.
Mar 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

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

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.
Mar 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

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.
Mar 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.

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.
Mar 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
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Mar 28, 2023 • edited

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.
Mar 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