Automate Work Log - Log 8h for everyday between two dates

Krzysztof Kiser January 13, 2021

Hi,

We are using Jira for time tracking, so when someone is working on an issue they would log the time in Jira.
For tracking purposes, we also need to log days off. 

We have a dedicated issue type for logging days off with custom start and end date fields.

Is there any way to automatically log work on that issue - 8h for every day between the start and end date (including those dates)?


We are doing this manually now, but would really like to automate if possible.

2 answers

0 votes
bmccoy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 13, 2021

Hi @Krzysztof Kiser 

You might be able to use the date functions in Automation.  The rule might look something like this:

Project automation - Jira 2021-01-14 09-52-38.png

The smart value in the screenshot is:

{{#=}}({{issue.Start Date.diff(issue.End Date).businessDays}}+1)*8{{/}}h

The diff function is not inclusive, that's why I have added + 1 to the result.

Cheers,
Brydie

Krzysztof Kiser January 13, 2021

@bmccoythanks for the suggestion.

I tried it, but I am getting an error:


Tried to copy value but fields are incompatible

Date Started : customfield_10409

Could this be because my start date field only includes date without a timestamp?
If so, is there a way to resolve this somehow without adding the timestamp to the field?

And also, I wanted to ask, will this log 8 hours for each day that would be between Start Date and End Date or will it log for example, if the duration is 2 days, 16h for the Start Date?

bmccoy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 18, 2021

@Krzysztof Kiser you're right, it's because the start date doesn't have a timestamp.  I've raised AUT-2114  to address this (fix on its way)

The formula I have used will get converted into the string "16h", which then gets logged as a single work log starting on the "Start Date". 

If you would like to log 8h on each day I think Don is on the right track using a Scheduled trigger.  To accommodate not logging twice for a single day I would only run your rule once a day, (the following day the conditions in the JQL would not be met anymore so the rule would not run).

Project automation - Jira 2021-01-19 13-29-40.png

The JQL in that example:

issuetype = Story and "Start date" <= "{{now.jiraDate}}" and "End Date" >= "{{now.jiraDate}}" and resolution = unresolved

Cheers,
Brydie

0 votes
Don Masten
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.
January 13, 2021
Krzysztof Kiser January 13, 2021

@Don MastenI do and I already looked at it. I don't see an option to log work for days between two dates.

Additionally, I need to be able to make one exception - if the start and end date are the same, only 8h are logged, not 16h.

Don Masten
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.
January 13, 2021

@Krzysztof Kiser did you try a cron with a jql? It might be easier to a second rule for your one exception.


image.png

Radka Svobodova July 4, 2023

is there a way to log work as the logAuthor=reporter? because this way the logauthor is jira automation, and than in timesheets it is not assigned to the real user.

Suggest an answer

Log in or Sign up to answer