Can you trigger an automation based on specific field value changes?
Asked by Dean Mervin _He_Him_They_:

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


Answers:
author: Trudy Claspill
body: Hello [@Dean Mervin _He_Him_They_](/t5/user/viewprofilepage/user-id/5528565)

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.

comments: author: Dean Mervin _He_Him_They_
body: Ok so I can get it to do one of the actions, but not the other...  

![Screenshot 2024-06-27 175914.png](https://community.atlassian.com/t5/image/serverpage/image-id/332208i019281B613E95609/image-size/large?v=v2&px=999 "Screenshot 2024-06-27 175914.png")![Screenshot 2024-06-27 180204.png](https://community.atlassian.com/t5/image/serverpage/image-id/332211i3EE22C4FA63F37C1/image-size/large?v=v2&px=999 "Screenshot 2024-06-27 180204.png")![Screenshot 2024-06-27 180226.png](https://community.atlassian.com/t5/image/serverpage/image-id/332212iD72B4A1A3F568173/image-size/large?v=v2&px=999 "Screenshot 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?


author: Trudy Claspill
body: Hello [@Dean Mervin _He_Him_They_](/t5/user/viewprofilepage/user-id/5528565)

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](https://community.atlassian.com/t5/image/serverpage/image-id/332220iF61B097D2600BBB6/image-size/large?v=v2&px=999 "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.png](https://community.atlassian.com/t5/image/serverpage/image-id/332224i49B1EB63EFDD031A/image-size/large?v=v2&px=999 "Screenshot 2024-06-27 at 10.40.40?AM.png")![Screenshot 2024-06-27 at 10.40.55?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/332223i7AC103B9C555D7E8/image-size/large?v=v2&px=999 "Screenshot 2024-06-27 at 10.40.55?AM.png")![Screenshot 2024-06-27 at 10.41.07?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/332227i10ED4A493EA3C805/image-size/large?v=v2&px=999 "Screenshot 2024-06-27 at 10.41.07?AM.png")


author: Dean Mervin _He_Him_They_
body: 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!


Tags: cloud

jira-service-management

jira-service-management-cloud