Forums

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

Jira Automation get last three days of the week

Jim Copeland March 14, 2022

I am trying to create an automation which checks to see if a status is unchanged after three days. If one of those three days was not a week day, it will ignore the ticket for that automation.

Right now my automation just runs on a schedule and pulls tickets that match this JQL value:
Screenshot 2022-03-14 233912.png

I know from here that there is a .dayofweekname property that can be pulled
https://support.atlassian.com/cloud-automation/docs/examples-of-using-smart-values-with-dates/

So I guess my ask is, Is there a way to a condition with logic like, "IF {{pastdays(3).dayOfWeekName}} CONTAINS regular expression (Sat|Sun) THEN ignore issue."

Is that something that can be done?

3 answers

1 accepted

0 votes
Answer accepted
Jim Copeland March 18, 2022

It looks like I may have been premature. Unfortunately this does not solve my problem. It seems like it is checking the value of *any* update in the past against the current time, not just status changes.

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.
March 18, 2022

Hi, Jim. 

Please take a look at the more advanced solution I noted earlier, where you use a custom field to track status changes with one rule and then use that value in your current one instead of Updated.

And if your workflow is very simple, such as ToDo, InProgress, and Done...there is a built-in field which can be used for this: statusCategoryChangedDate

Thanks,
Bill

Jim Copeland March 18, 2022

Ah! Thanks for those resources. After testing with a manually triggered rule, I found the smart value I am looking for. For anyone else looking to do this, the logic is:

If
{{issue.statuscategorychangedate.toDate.diff(now).businessDays}}
is greater than 2

then
comment and close the ticket

1 vote
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.
March 15, 2022

Hi @Jim Copeland 

Would you please clarify your use case?  Are you trying to report:

  1. any issues which have not changed status ON the third business day  (i.e. issue appears only on one report for a given status)
  2. any issues which have not changed status IN AT LEAST three business days (i.e. once the issue appears on the report, it continues to be reported until something changes)

For either you may want to consider a date diff and business days to check the number of elapsed business days since a change: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/

Kind regards,
Bill

Jim Copeland March 15, 2022

Hi Bill, 

Thank you for looking at my question. In this case, my question would apply to your second scenario. Any status would has not changed in at least 3 business days.

From what I can tell, however, getting a date diff does not include the names of the days of the week?

Thanks again,

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.
March 15, 2022

Hi Jim,

When JQL does that search for the trigger, it is running against the issue history...and we do not have access to that in an automation rule (unless you call the REST API).

Let's consider the simplest way to solve this: comparing the updated date to now.  If we assume the last issue update was to the status, then you may ignore the day of week names and just check business days diff using and advanced compare condition:

  • first value: {{issue.updated.diff(now).businessDays}}
  • condition: greater than
  • second value: 2

But what if the issue was updated for other reasons, such as adding a comment?  For a more advanced solution, you would need a custom field to save the date/time whenever an issue transitions to a new status.  You may do this with a second rule:

  • trigger: issue transitioned
  • action: edit the custom field with {{now}}

Now your scheduled trigger rule can perform the reporting by comparing the custom field to {{now}}

Jim Copeland March 16, 2022

Hi Bill,

Fortunately, in our environment, when a comment is added the status is automatically updated, so I think your first answer should be perfect!

Thank you so much. Side note, is there a resource I can refer to to get a list of all the smart values and how they can be used together?

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.
March 16, 2022
0 votes
Jim Copeland March 18, 2022

Ah! Thanks for those resources. After testing with a manually triggered rule, I found the smart value I am looking for. For anyone else looking to do this, the logic is:

If
{{issue.statuscategorychangedate.toDate.diff(now).businessDays}}
is greater than 2

then
comment and close the ticket

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events