Forums

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

Can you trigger an automation based on specific field value changes?

Dean Mervin _He_Him_They_ June 27, 2024

We want to create an automation that adds a label of "severity_increased" or "severity_lowered" when our severity field on a JSM ticket is moved up or down (For context, clients may raise service desk issues at a higher severity than is appropriate so we need to de-escalate them and vice versa).

 

I can see that its possible to add a label with the field being edited in any way, which would be perfect if we just wanted to log that it was changed, but can I define which label is used if it moves from one value to another.

i.e. severity modified from Critical to High, Medium or Low = add label "severity_lowered".

1 answer

1 accepted

0 votes
Answer accepted
Trudy Claspill
Community Champion
June 27, 2024

Hello @Dean Mervin _He_Him_They_ 

Welcome to the Atlassian community.

Yes, you can do that with Automation.

With the Field Value Changed trigger you get access to the values of the field before and after the change with the special smart value {{fieldChange}}

https://support.atlassian.com/cloud-automation/docs/jira-automation-triggers/#Field-value-changed

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

You can use Conditions to evaluate the before and after values and then edit the issue to add the Label value that is appropriate.

Dean Mervin _He_Him_They_ June 27, 2024

Ok so I can get it to do one of the actions, but not the other...

Screenshot 2024-06-27 175914.pngScreenshot 2024-06-27 180204.pngScreenshot 2024-06-27 180226.png

 

This is how I've got the first IF block set up, so I've got it going from the higher severity values down to any lower severity value, and adding the severity_lowered label.

The ELSE block is then just for anything that isn't that, adding the label of severity_increased.

The severity_lowered label is applied, even when those conditions aren't met, so going from Low to Critical I still get the label of severity_lowered.

I'm now stuck 😅 do I just need to do another automation that's a mirror for the changes going in the opposite direction? Rather than trying to use IF/ELSE?

Trudy Claspill
Community Champion
June 27, 2024

Hello @Dean Mervin _He_Him_They_ 

So, first thing, the smart value {{fieldChange}} should not be preceded by issue.

Don't use {{issue.fieldChange...}}

Do use {{fieldChange...}}

Second, you are trying to access things that are not part of the {{fieldChange}} structure; namely fromHigh, toLow, fromMedium, etc. The {{fieldChange}} smart value has very specific attributes you can access as detailed here:

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

If you want to reference the value of the field before it was changed you use {{fieldChange.fromString}}. If you want to reference the value of the field after it was changed you use {{fieldChange.toString}}

In my environment the Severity values are Sev-0, Sev-1, Sev-2, Sev-3, going from highest severity to lowest severity.

To determine if the Severity has been decreased I can use If/Else blocks like this.

Screenshot 2024-06-27 at 10.38.50 AM.png

You would make a series of if/else blocks to check for severity decreases, and then a set checking for severity increases.

There may be a more elegant/efficient way to do this, but this seems to work.

Screenshot 2024-06-27 at 10.40.40 AM.pngScreenshot 2024-06-27 at 10.40.55 AM.pngScreenshot 2024-06-27 at 10.41.07 AM.png

Like # people like this
Dean Mervin _He_Him_They_ June 28, 2024

You are a superstar, thankyou that works perfectly.

I was getting a bit overzealous adding in the issue bit at the beginning, from past experience I thought that needed to be added in too 🤦

 

Much appreciated!

Suggest an answer

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

Atlassian Community Events