Community Announcements have moved! To stay up to date, please join the new Community Announcements group today. Learn more
×I'm attempting to automatically log work based on comments which include a "unit of time". If for example a comment is left on the ticket saying "I worked for 45m doing a report on this" it would automatically log 45m of work on the ticket and provide the description as "I worked for 45m doing a report on this".
I've created an automation rule that firstly checks if the comment includes the regexp (\d+)([mhd]). I then create a test action to write a comment of the format {{issue.comments.last.body.regexpMatch("(\d+)([mhd])")}}, this returns empty in the audit log though, wondering if this is the correct way to go about it or if some syntax has changed.
Thanks!
Hi @James Purcell and welcome to the community!
I need to ask why you would go through this effort vs simply adding the native time tracking field to your issue which offers the ability to add time and comment.
Additionally, by using automation you'll have an extra layer of identifying who recorded the work as it will always record time as the rule actor instead of the individual logging time.
Lastly, automation rules based upon comments are costly in terms of general performance because they will typically trigger more than any other rule.
All that said, if you still wish to go this route, I would try this for the regex:
{{issue.comments.last.body.match("\d+[mhd]")}}
Hi @Mark Segall ,
Thanks for the reply, unfortunately with a test comment of
"hello 2h world" it still comes back that your regex is empty.
The idea was, we currently leverage a slack channel which creates threads when a Jira ticket is created (through a separate automation), raising a thread comment on that slack post will add a comment to the Jira ticket, I then want to use the comment automation to log work on Jira if the Slack comment includes regex of the format \d+[mhd]. That way any practitioner within the channel can simply use slack to post comments on multiple tickets and the work be logged accordingly. It doesn't matter too much if the logger is automation or someone specifically.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the added context. I'm very familiar with corporate slack addiction. My bad on the expression... Forgot to include the parentheses:
{{issue.comments.last.body.match("(\d+[mhd])")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Mark Segall , thanks for this, this works, however for anyone else viewing this, when you @ someone within a Jira ticket, it will use their UID within the comment text for smart values. This means if someone had an UID which looked like <...400d1h...> it would log 400days and 1 hour onto the ticket. Have now updated the time spent field to
{{issue.comments.last.body.match("(\b\d+[dhm](?=\s|$))")}}
After an awkward ticket had 800 weeks logged of work!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.