Setting an assignee with automation: How to email both old and new assignee?

Louise Baker
Contributor
July 18, 2024

My automation's end goal is this:
- Issue has Field X updated
- Update Field Y (user picker) based on Field X's value
- If Field Y had a previous value (user), email old value and new value

Bullet Point 1 and 2 working great.

Things aren't working at the email step (bullet point 3)

As part of Bullet Point 1, I'm creating two custom variable to record the current Field Y's value (display name and email). Then, in Bullet Point 3, I'm trying to email the old value and the new value. This is working, however the values for my custom vairaibles and Field Y are the same. It's as if Field Y's new value isn't available at the time of the rule.

I'm using an If Else branch to accomplish Bullet Point 2 because we have 5 possible Field Y users and ~30+ Field X values (If field X equals one of these, update Field Y to User 1, else if field X equals one of these, upate Field Y to user 2 etc)

I can't figure out if I need a new custom variable that's set after each If Else... and then I use that? But that's a very manual process and seems wrong.
I've wondered if I needed to just move the email step to the end after each If Else as well, but that seems manual too (I'll have to write in the users email directly.. seems not correct?)

So I'm wondering if I'm just missing something obvious?

 

Screenshot 2024-07-18 at 12.21.50 PM.png

In the log step, I've also tried these fields to no avail:

{{issue.customfield_10215.displayName.fieldChange.toString}}
{{issue.customfield_10215.fieldChange.toString}}
{{customfield_10215.toString}}
{{#changelog.customfield_10215.displayName}}{{toString}}{{/}}
{{#changelog.customfield_10215}}{{toString}}{{/}}

{{fieldChange.toString}} did result in something, but it was showing me the changed value of Field X, when I need to access Field Y (customfield_10215)

2 answers

1 accepted

0 votes
Answer accepted
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.
July 18, 2024

Hi @Louise Baker 

When a rule edits a field, it is based on the issue's data at the current time, usually the time was rule triggered.  The edited data is saved in the cloud, but not updated in the stored values within the running rule.  (This helps with some use scenarios and yet can confuse rule writers.)

And so when you edited the field and then checked it afterwards, it had the original value.

When you want a rule to use the updated values, add a Re-fetch Issue action after the edit to refresh it:

  • trigger: value changed for your field
  • action: create variable to save the value
  • ...
  • conditions and actions to edit the field
  • action: Re-fetch Issue
  • action: write the values to the audit log
  • ...

 

Kind regards,
Bill

Louise Baker
Contributor
July 19, 2024

THANK YOU!!! This was exactly what I needed. The rest of the rule as I had it worked 100% after that. Appreciate you so much!

Like Bill Sheboy likes this
1 vote
Pramodh M
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 18, 2024

Hi @Louise Baker 

I believe it is the same scenario discussed here, can you please check this thread and see if the solution works?

https://community.atlassian.com/t5/Marketplace-Apps-Integrations/How-to-get-the-previous-value-of-the-field-in-jira-email/qaq-p/1897271

Thanks

Louise Baker
Contributor
July 18, 2024

If it answers it, I still can't figure it out.
I am trying the tostring recommended, and nothing is showing at all in my audit log.
I've also read https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/ and https://community.atlassian.com/t5/Jira-Service-Management/How-do-I-compare-the-fromString-and-toString-for-just-the-parent/qaq-p/1512678 and neither of these are getting me closer :(

Louise Baker
Contributor
July 18, 2024

I was able to get some value to display for {{fieldChange.toString}}, however what it's doing is showing me the changed value for Field X (which is not being changed IN the rule itself), rather than the changed value for Field Y (which IS being changed in the rule itself and what I need to reference)

Field Y's  field is customfield_10215, and these below yielded no result at all:

{{issue.customfield_10215.displayName.fieldChange.toString}}
{{issue.customfield_10215.fieldChange.toString}}
{{customfield_10215.toString}}

I even tried

{{#changelog.customfield_10215.displayName}}{{toString}}{{/}}

{{#changelog.customfield_10215}}{{toString}}{{/}}

And still nada

Suggest an answer

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

Atlassian Community Events