Forums

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

Filtering comment time stamp to notify specific members

Michael Vidallon November 4, 2022

Hello,

I am trying to utilize Automation for Jira to check if specific comment by customer falls under a certain time of the day, it will notify different people depending on the time the comment is made.

For example, I have 3 teams

Team 1 - 12AM to before 8am ET

Team 2 - 8am-4pm ET

Team 3 - 4pm ET to before 12MN

So for example, if customer comment is made between 8am-4pm ET, it should send email (automation rule action) to Team 2. Same thing other time of the day to notify either Team 1 or Team 3.

{{issue.comments.last.created}}

less than

startOfDay()

Tried the above Advanced Compare condition or even If/else via JQL (where I am able to identify the short time through this:

{{issue.comments.last.created.shortTime}}

 But JQL parsing errors shows as when value returns 2:48 PM (or any time)

Error in the JQL Query: Expecting operator but got 'PM'. The valid operators are '=', '!=', '<', '>', '<=', '>=', '~', '!~', 'IN', 'NOT IN', 'IS' and 'IS NOT'.

 

I would appreciate any feedback and suggestions.

2 answers

0 votes
Rafael Costa
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.
November 5, 2022

I would can to do it by myGroovy plugin, if you have it on your Jira instance. But how would be this team notification? Via e-mail?

Michael Vidallon November 8, 2022

The notification is via email Rafael.

0 votes
Luis Machado
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 4, 2022 edited

Hi @Michael Vidallon ,

This was an interesting one to try to solve. The inherent problem with leveraging time as a variable in cloud is all of the functions like startOfDay() are relative to the server time.

When you're viewing time through the UI, it converts the values based on the default timezone set in the server settings but doesn't necessarily match the value stored. So part of your solution has to include converting the comment timestamp and the value you're comparing against into the timezone you're working with.

As an example, when I was running a test

{{issue.comments.last.created.shortTime}} 

gave me "7:49 PM", but when I used the function to convert it to my timezone

{{issue.comments.last.created.convertToTimeZone("America/Chicago").shortTime}} 

I got "2:49 PM" as an output.

The example below is using the server time for the instance I'm working with, but that might not reflect the server time of your instance. I would recommend running a log action to output:

{{now}}

{{now.convertToTimeZone("America/New_York")}

to find the differential.

Here's the comparison I put together that fits your 'Team 1' example:

Screen Shot 2022-11-04 at 7.25.56 PM.png

The first value converts the comment timestamp to the EST timezone, the second is the time value to compare against.

{{now.toStartOfDay.minusHours(20).convertToTimeZone("America/New_York").shortTime}}

There are two advanced compares with an AND statement in between so you can ensure the value sits between the two target times. In the example above it's greater than Midnight, and Less than 8 AM.

When you craft your rule then, you can use an if/else block with two of these advanced compares for each set of times making adjustments with the minusHours() or plusHours() function as necessary to give you the desired value.

Michael Vidallon November 8, 2022

Thanks Luis. Will consider these suggestions.

Suggest an answer

Log in or Sign up to answer