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

JSM Custom Notification

Natasha Richardson August 27, 2023

Hi all. I am looking for assistance on a custom JSM notification I've created in Legacy Automation that is not executing due to the JQL condition not being met. 

I am a bit confused because the JQL query works when I type it in the search issues and successfully pulls up the issues that meet the condition. This is the query: (created >= startOfWeek("-1d") AND created <= startOfWeek("+1d"))

The query is checking for issues created on Saturday and Sunday.

My custom alert logic is simple:

When an issue is created,

if (created >= startOfWeek("-1d") AND created <= startOfWeek("+1d"))

then send an email

 

Thanks in advance for the assistance

Natasha

5 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
1 vote
Answer accepted
Cassie the Jira Mechanic
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 28, 2023

@Natasha Richardson I would approach this a bit differently.  I would make sure I have SLA calendars in my JSM desks are set correctly to match my Agents's schedules.  Then I would use SLA JQL:
withincalendarhours()
to filters issues whose SLA clock is not running according to the SLA calendar. WithinCalHours.JPG
I hope this helps!
( More info about SLA related JQL:  Using JQL queries specific to SLAs | Jira Service Management Data Center and Server 4.18 | Atlassian Documentation)

Natasha Richardson August 28, 2023

Thanks. Yeah, there are a few different ways to do this for sure and your approach seems much simpler. I may tweak it anyway because I didn't include after-hours for during the week. I asked Chat GPT and it gave me createdDate >= startofDay("America/Chicago") AND createdDate <= endofDay("America/Chicago") AND createdDate NOT BETWEEN startofDay("America/Chicago 08:00") AND startofDay("America/Chicago 17:00"))

 

This translates to tickets created outside of the specified business hours (8 am-5 pm) M- F in the Central Time Zone. It uses the NOT BETWEEN clause to exclude tickets created between 8 a.m.-5 pm M-F.

I didn't know you could directly specify a timezone in the query like that so that is pretty neat as well. I do have to consider different time zones with this setup for India, London, Poland, Brussels, Chicago, and some others.

 

This one ChatGPT wrote taking timezones into consideration but it says to replace the timezones with the relevant ones for your business hours.

createdDate >= startofDay("+05:00") AND createdDate <= endofDay("+5:00") AND createdDate >= startofDay("-7:00") AND createdDate <=endofDay("-7:00")

Natasha Richardson August 30, 2023

Hi,

I'm not having much success with this feature. We have our calendars created and time to acknowledge and time to resolution SLAs set up. I'm using the legacy automation bc the format of the notification looks like the standard customer notification but for some reason the automation doesnt seem to be detecting the issues sla isnt running when i create a test ticket. I have today's date in as a holiday just for testing purposes and I've tried with '=' and '!='

Am I missing something here?

 

TIScreenshot 2023-08-30 at 1.56.43 PM.pngScreenshot 2023-08-30 at 1.57.37 PM.pngScreenshot 2023-08-30 at 1.58.59 PM.png

Natasha Richardson September 3, 2023

Answer accepted with one caveat, you will need to stack the re-fetch issue action to the automation otherwise, running this with the Issue Created option doesnt allow time for the SLA timer to be evaluated before the rule completes. Same goes for trying to evaluate the created date field.

This is a known issue:

https://jira.atlassian.com/browse/JSDCLOUD-8893

 

Post on re-fetch

https://community.atlassian.com/t5/Jira-questions/Is-there-anyway-to-add-a-quot-time-delay-quot-for-everyactions/qaq-p/1447213

https://jira.atlassian.com/browse/AUTO-238

Like Kalin U likes this
0 votes
Cassie the Jira Mechanic
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 30, 2023

@Natasha Richardson find me on LindedIn and shoot me a message I'll make time to help you the best I can!

0 votes
Lewis Cook
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.
August 30, 2023

Suggesting a slightly clunkier approach from how I've set stuff up on our service desk.

For context, we track the day and month issues are created as custom fields for reporting and trend purposes using the following automation rule:

Screenshot 2023-08-30 100626.png

 

Following on from the above it would certainly simplify the JQL for your notification rule to be :

"Day Created" in (Sat,Sun)

Natasha Richardson August 30, 2023

Thanks. I'm going to try Cassie's approach because we need to include Holiday hours as well for all of our locations and we can plug in Holidays in the SLA calendars so this should be easy but it's not working for me. 

0 votes
Kalin U
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.
August 27, 2023

Your JQL statement in your post should work for issues created in the most recent weekend, with a slight change though:

created >= startOfWeek("-1d") AND created < startOfWeek("+1d")
  • >= startOfWeek("-1d") translates to on or after Saturday
  • < startOfWeek("+1d") means before Monday

Can you share a (redacted) screenshot of your automation rule?

What don't you expect to see in the results?

Natasha Richardson August 28, 2023

Hi Kalin. Thanks for the response and yes, I want to capture tickets that come in over the weekend and basically send an email to the customer saying you've reached us after hours, etc. 

When I removed this part 'AND created <= startOfWeek("+1d"))' the results returned tickets created on Monday. I am in Chicago so was testing this over the weekend last night. I created a ticket after Midnight and the JQL included that ticket when I removed the AND clause. Not what I want.

So the original JQL query works to filter only to Saturday and Sunday but for some reason, the Custom Notification I created didn't execute because it said conditions weren't met. 

I wonder if maybe the rule is looking for the ticket to exist first and then evaluate the date? But that can't be right because it should be checked when the issue is created.

 

Screenshots of Custom rule attached

Screenshot 2023-08-28 at 9.15.25 AM.png

 

Screenshot 2023-08-28 at 9.14.52 AM.png

Like Kalin U likes this
Natasha Richardson August 28, 2023

My man. I think your slight change did it. Removed the = in the second part of the clause and just sent a ticket and it executed the way I wanted. I'll have to wait until the weekend though to see if it's working for Saturday and Sunday.

Screenshot 2023-08-28 at 9.30.13 AM.png

Like Kalin U likes this
Kalin U
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.
August 29, 2023

@Natasha Richardson Please follow up with your latest observations. Also, did you check your Jira's instance time settings:

K.

Like Natasha Richardson likes this
Natasha Richardson August 31, 2023

@Kalin U Our timezone is set to the system default

Screenshot 2023-08-31 at 1.05.41 PM.png

Natasha Richardson September 3, 2023

@Kalin U 

OK, I tried so many workarounds its too much to type but ultimately with this query and the created date, the automation was executing too quickly before the rule could evaluate the conditions and thus my IF statement kept returning "no issues found to match condition" and sending the wrong email notification.

Since I also needed to implement this automation for holidays and after-hours during the week, I went with the solution suggested by Cassie and used withinCalendarHours(). I ran into the same issue though with the rule executing too quickly before the SLA timer could be applied. This is actually a known issue

https://jira.atlassian.com/browse/JSDCLOUD-8893

 

I just found a workaround using the tidbit from these articles. I stacked the re-fetch issue option 10x before executing the IF and that worked. It is not pretty but gets the job done for me for now. 

https://community.atlassian.com/t5/Jira-questions/Is-there-anyway-to-add-a-quot-time-delay-quot-for-everyactions/qaq-p/1447213

https://jira.atlassian.com/browse/AUTO-238

Like Kalin U likes this
Kalin U
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.
September 3, 2023

Thank you for describing your solution and the paths you took. Yes, unfortunately, there are less known issues with either automation (legacy and modern) that make us spend time troubleshooting them.

Yes, Cassie's solution is elegant plus your forcing a delay after the trigger.

Did you ultimately choose the legacy or modern Automation feature?

Natasha Richardson September 4, 2023

@Kalin U I used the modern automation feature. The re-fetch issue isn't an option on the legacy side.

Like Kalin U likes this
0 votes
Natasha Richardson August 27, 2023

I removed the AND part of the query and got it to work. 

Natasha Richardson August 27, 2023

Bugger. Removing that AND clause doesn't exclude weekdays. 

TAGS
AUG Leaders

Atlassian Community Events