How to display all worklogs for the last week in the smart values?

Halyna Rudych July 24, 2024

Hi!

I am trying to use Jira Automation rule and send a scheduled email with the worklogs made within the last week however this filter seems not working. 

I will appreciate your help!

I am using this email content.

 

{{#issues}}

{{#worklog}}

{{#if(now.minusWeeks(1).isBefore(created))}}

Issue: {{key}}

Summary: {{summary}}

Assignee: {{assignee.displayName}}

Worklog Author: {{author.displayName}}

Time Spent: {{timeSpent}}

Worklog Created: {{created.format("yyyy-MM-dd HH:mm")}}

{{/}}

{{/}}

{{/}}

 

JQL that is used to lookup the issues:

project = PROJECT_NAME AND type IN (Epic, Bug, Story, Task, Sub-task) AND worklogDate >= startOfDay(-7d) ORDER BY created DESC

 

3 answers

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.
July 25, 2024

Hi @Halyna Rudych 

For a question like this, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected.  Those will provide context for the community to offer ideas.  Thanks!

Until we see those...

1) As described by @Wojciech Wardaszko [HeroCoders] the plural smart value {{issues}} is used by Jira Server and Data Center for bulk-issue handling, and is apparently not supported for Jira Cloud.  IMO, any values you see from it are likely unsupported and unpredictable.  Instead, try the Lookup Issues action to gather the issues for batch processing.

2) Also, when inside of an iterator such as {{#lookupIssues}} ... {{/}} the issue. prefix is not needed as the scope is the lookup results.

3) Next, do you want to check when the worklogs were created or started (when the person indicated the work happened)?  For now, I will assume started as that defaults to the created value if started is not entered by a person.

 

Using Lookup Issues and the worklog smart value, you may use the started attribute for filtering on the date range.  Please note well: according to the documentation, the worklog smart value is only used with the Work Logged trigger: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--worklog--  However its seems to available for the more recent entries also.  (To see older log entries, or when there are many log entries, a rule will need to call the REST API with filtering on the timestamp, one issue at a time.)

Assuming you want to filter for the last 7 days (which is what your filter shows), you could try this expression:

{{#lookupIssues}}
{{key}} - {{summary}} assigned to {{assignee.displayName}}.
Worklogs in the last 7 days:
{{#worklog}}
{{#if(started.isAfter(now.minusWeeks(1).toDateTimeAtStartOfDay))}}
Time tracked by: {{author.displayName}}
Time spent: {{timeSpent}}
Worklog date & time: {{created.format("yyyy-MM-dd HH:mm")}}
{{/}}
{{/}}
{{/}}

Some things about this one:

  • it does not handle unassigned issues; the value will be null for the assignee
  • it does not handle no worklogs found for the last 7 days
  • it does not handle time zone impacts for the week adjustment; however, I did adjust to the start of the date selected so the entire day is covered, regardless of when the rule is run relative to {{now}}

Kind regards,
Bill

0 votes
Wojciech Wardaszko [HeroCoders]
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.
July 24, 2024

Hi @Halyna Rudych,

I haven't tested it so I'm just speaking from my knowledge of how automation rules work, but IIRC the {{worklog}} smartvalue is only available when the trigger is set to Work Logged.

I'm also not sure about the {{#issues}}, I think you're looking for {{#lookupIssues}} since you referenced using the Lookup issues action with the JQL filter.

You could try accessing {{#issue.worklogs}} inside the {{#lookupIssues}} loop, but you'd need to do it a little differently - you're trying to fetch things from different scopes all together.

Again, not tested, but I think something like this would have a better shot at working:

{{#lookupIssues}}
{{key}} - {{summary}} assigned to {{assignee.displayName}}.
Worklogs:
{{#issue.worklogs}}
{{#if(now.minusWeeks(1).isBefore(created))}}
Time tracked by: {{author.displayName}}
Time spent: {{timeSpent}}
Worklog date & time: {{created.format("yyyy-MM-dd HH:mm")}}
{{/}}
{{/}}
{{/}}

I hope this helps or at least guides you in the right direction.

Alternatively, you could just use our app, Clockwork Free or any other free timesheet app to get the necessary report without going through all this ;)

Cheers!

Halyna Rudych July 25, 2024

Hi @Wojciech Wardaszko [HeroCoders] ,

 

Thank you for your suggestion! Unfortunately, it didn't help. The problem is that this filter doesn't filter the worklogs correctly. Only this seems to be a problem, because when I am removing it at all then I receive an email with all worklogs.

{{#if(now.minusWeeks(1).isBefore(created))}}

 

I can't figure out why it doesn't work. I will appreciate your further help. Thanks!

0 votes
Halyna Rudych July 24, 2024

Hi @Bill Sheboy! I noticed your extremely good expertise around this area and I was wondering if you could help. I will greatly appreciate it!

Suggest an answer

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

Atlassian Community Events