Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,295,646
Community Members
 
Community Events
165
Community Groups

Be notified, if somebody adds old worklog to your project

Situation

Description

One of my customers asked me to help with their situation.

This company has a lot of customers with monthly "Time & Material" billing, which means all the worklogs from the customer's project from the previous month are taken and based on the sum of logged hours the invoice for customer is prepared.

To be able to prepare the invoice, all the work needs to logged in Jira no later than the tenth day of the following month.

But it happens occasionally logs are created later, which means these hours are not billed to the customer.

The company is in process of adopting Tempo Timesheets, which enables you

  • to lock the previous month, so the users are not able to add/delete/modify the old worklogs
  • do the timesheets approvals for each month - this way you can confirm with the users they have logged everything and also lock their timesheets

But the process of adopting needs some time and a few users are still not able to send the timesheets for approval on a monthly basis...

What can be done?

As a project leader you can be notified about all the changes in worklogs (based on the Jira's notification scheme), but if there a lot of changes, you don't want to read all the email notifications.

So I've prepared a special automation rule to notify the project leader, if somebody is trying to add the "old" worklog, so the project leader can react on this situation.

What does it mean "old" worklog?

During the month there are two different situations:

  1. In the beginning of the month (from 1st to 10th day of month) users can log their work to the current and also the previous month - if a worklog starts before the first day of the previous month, it is considered as "old"
  2. Later in the month (from 11th to 31th day of the month) users can log their work only to the current month - if a worklog starts before the first day of the current month, it is considered as "old"

Preparations...

Selection of the trigger

I wanted to do some action based on worklog creation, so Work logged trigger is a definitely the right choice. There's also possibility to react only on some operations (e.g. only to creation, not modification or delete). In the end I've decided to react on all the operations, because it could also be interesting for the project leader to know about the modifications and removals of worklogs.

Variables - here comes the smart values

There are four dates I needed to work with:

Worklog start date

{{worklog.started}}

This smart value is available because I've used the Work logged trigger.

Today's day of month

{{now.dayOfMonth}}

First day of the current month (midnight of the date)

{{now.startOfMonth.withHour(0).withMinute(0).withSecond(0).withMillis(0)}}

First day of the previous month (midnight of the date)

{{now.startOfMonth.minusMonths(1).withHour(0).withMinute(0).withSecond(0).withMillis(0)}}

Detect the situation based on the today's day of month

This can be done using the Advanced compare condition.

Smart value

{{now.dayOfMonth}}

returns the number, e.g. on the 25th February returns 25, we can compare it with any number:compare_day_of_month.png

{{now.dayOfMonth}} is less than 11

means the first situation - from 1st to 10th day of the month.

Detect, if worklog is "old"

This can also be done using the Advanced compare condition.

compare_worklogs.png

I can simply compare two dates, which one is earlier.

Action

I was asked to simply send email to the project leader.

It is possible to use some worklog smart values (these are available because of the used trigger) in the email's body like

{{worklog.comment}}
{{worklog.started}}
{{worklog.timeSpent}} (cloud only)
{{worklog.timeSpentSeconds}}

to add some information about the worklog. The most important is to provide issue's key using

{{issue.key}}

so the project leader knows, which issue is involved.

Let's create the automation rule

When: Work logged (all worklog operations)

If: all match

  • {{now.dayOfMonth}} is less than 11
  • {{worklog.started}} is less than {{now.startOfMonth.minusMonths(1).withHour(0).withMinute(0).withSecond(0).withMillis(0)}}

-> Then: Send email

Else-If: all match

  • {{now.dayOfMonth}} is greater than 10
  • {{worklog.started}} is less than {{now.startOfMonth..withHour(0).withMinute(0).withSecond(0).withMillis(0)}}

-> Then: Send email

 

rule.png

Improvements?

What if I need to work with various days of month?

In the Advanced compare condition you can always use regular expressions like:

(1[5-9]|2[0-5])

This means from 15th to 25th day of the month

compare_regular.png

Is it really necessary to have the rule divided into two sections with the same action?

It would help, if the variable with the date can be set, something like "if we are in the beginning of the month, set the variable to the first day of the previous month, else set the variable to the first day of the current month".

Even though it is possible to create variables in Jira cloud, I wasn't able to make this conditional behavior work.

Can this be done in a more easier way / differently?

Probably yes! There are so many possibilities for automation, so please let me know your thoughts and suggestions. Thank you!

6 comments

Great article, @Hana Kučerová. I've actually been asked for this kind of "post-dated time logging alerts" also.

Another feature of Tempo Timesheets is a custom "grace period" where a Timesheet Approver can provide some extra time for people to log time after a Timesheet Period has ended. More here:

https://help.tempo.io/cloud/en/tempo-timesheets/approving-timesheets/granting-a-grace-period-to-team-members.html

This can help bridge some of the people who tend to be tardy, and have difficulty getting all their logged time in the system by the end of each billing period (typically monthly).

An approach I've taken that has really helped is to increase visibility of logged time to the team. I pull up a logged time report twice per week in the team standup meetings. Everyone can then see their logged time to-date, and it also allows me to talk about time logging often, and stress the importance of that data to the company for financial reasons. Having leaders reinforce those messages during the standup is helpful too.

It is difficult to get into new habits. Time logging is one of those necessary habits, and with a greater use of remote work now, it's something we can help coach our teams into these new patterns.

Like # people like this
Hana Kučerová Community Leader Jul 26, 2021

Thank you, @Mykenna Cepek , for sharing this, I really appreciate it.

Like Mykenna Cepek likes this
Sajit Nair Community Leader Jul 26, 2021

This look great @Hana Kučerová 
Definitely trying this one out for my own instance.

Like Hana Kučerová likes this

How would you set the compare condition to work for time spent changes to a worklog? I can get the new value, but not the old one. I tried this, but it just gives me the new value.:

{{worklog.timeSpent}}{{fromString}}

and also:

{{worklog.timeSpent.fromString}} 

but that only seems to give me the remaining estimate, not the actual time logged.

Hana Kučerová Community Leader Aug 28, 2021

Hi @Lissa Meade ,

I don't think this is possible. The trigger used is Work logged and therefore worklog smart value is available, but it accesses only information for a worklog entry that has just been logged against an issue (not the previous values).

Mykenna Cepek Community Leader Aug 28, 2021

@Lissa Meade I was going to suggest how the Jira REST API might help with your use-case (looking at issue history aka changelog), but I found this discussion which does a fine job on the topic:

https://community.atlassian.com/t5/Jira-Software-questions/Can-t-access-issue-history-through-changelog-in-Automation-for/qaq-p/1595792 

Like Lissa Meade likes this

Comment

Log in or Sign up to comment
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you