Forums

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

Time tracking automation not working

Alex Magee October 21, 2022

Hi Team!

So I want to log time spent on tasks automatically.

I have a custom field "Worklog", which records the date when the task accepted the "In Progress" status. When the status changes, the worklog should record the difference between the "worklog" field and the current date in minutes.

The problem is that every time the automation is triggered, in the audit log I see the error:

"Error trying to log work against an issue. Invalid date format. Please enter the date in the format "yyyy-MM-dd'T'HH:mm:ss.SSSZ". (started)."




Screenshot 2022-10-21 at 17.17.20.png
Screenshot 2022-10-21 at 17.18.05.png
Screenshot 2022-10-21 at 17.18.36.png

3 answers

0 votes
Tharaka_Hettiarachchi
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.
October 22, 2022

Hello @Alex Magee ,

I think its the issue with smart values. Please check this.

 

https://www.youtube.com/watch?v=XnGxc7C3hZc

 

Cheers!

Alex Magee October 25, 2022

Hi @Tharaka_Hettiarachchi , 

I also tried your video but doesn't seem to work also? 

0 votes
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.
October 21, 2022

Hi @Alex Magee -- Welcome to the Atlassian Community!

I believe both your smart values and the time logging have some issues...

  • First thing: {{issue.worklog}} is a built in smart value!  Have you really defined a custom field which is also named "WorkLog", with the only difference in capitalization?  If so, that is generally a bad idea and I advise you to rename the custom field.
  • When you have a custom field in an issue, the smart value is typically referenced as {{issue.myCustomFieldName}}
  • And for time logging you need the units of measure, such as an "m" for minutes.

Please note: what you have described shows the full date/time difference between the starting point and {{now}}, so for issues which span days that will be reflected in the logged value.  Is this what you really wanted?

As you have described the use case...your information for that field would probably be this:

Time spent:

{{issue.WorkLog.diff(now).minutes}}m

Date started:

{{issue.WorkLog}}

 

If that does not work please confirm the name of your smart value for the field using this how-to article: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

Kind regards,
Bill

Alex Magee October 25, 2022

Hi @Bill Sheboy , 

So I decided to change the custom field to 'LogTime' and used your smart values above but still, nothing is being tracked or automated?

RE full date/time difference. I mean I do want it on a granular level so the this would be a requirement.

 

Screenshot 2022-10-25 at 09.37.26.pngScreenshot 2022-10-25 at 09.37.10.pngScreenshot 2022-10-25 at 09.36.56.png

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.
October 25, 2022

In your screen images, the LogTime field is empty, and so I would not expect a value to be created for the diff().  Did you post the correct images?

What is the type of your LogTime field: text, date/time, something else?

Next, have you confirmed that "LogTime" is the correct smart value for that field name?  To check on that, please use this how-to article: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

0 votes
Trudy Claspill
Community Champion
October 21, 2022

Hello @Alex Magee 

Welcome to the community.

When I get errors like that I like to add Log Action actions to my rule to print out to the rule Audit Log the values that the rule is trying to use. This can help you figure out if the value you are trying to use matches the field type where you are trying to use it. You may need to do some conversion or formatting. The error message suggests you need to format the data, but you may find that the value referenced isn't even valid.

Looking at the last image you posted it appears that the "Worklog: Start Date" field has no value. What type of field is that? I think you need to go back to the rule (or workflow transition) that sets that field and find out first why that field is blank. Given that it is blank, then your rule actions to try to set another Date/Time field to that value understandably won't work.

Alex Magee October 25, 2022

Hey @Trudy Claspill 

It's a very good point. So I thought the value would be populated when you move it across statuses? Is this not correct? If not, how do you set the transition to populate it first?

I've now changed the field names to make it easier. 

Screenshot 2022-10-25 at 09.37.26.pngScreenshot 2022-10-25 at 09.37.10.pngScreenshot 2022-10-25 at 09.36.56.png

Trudy Claspill
Community Champion
October 25, 2022

If LogTime is a custom field you created, Jira will not set that field to any value unless you provide it the instructions to do that. Have you modified the Workflow Transition so that field will be set when the issue transitions to In Progress?

Alex Magee October 25, 2022

I have not modified the Workflow Transition so that field will be set when the issue transitions to In Progress - How can I do this?

Trudy Claspill
Community Champion
October 25, 2022

You would need to add a Post Function to the workflow transition to set the field value.

https://support.atlassian.com/jira-cloud-administration/docs/edit-an-issue-workflow/#Configure-post-functions

Alex Magee October 26, 2022

Perfect thank you @Trudy Claspill 

So I've added the following post function logic to the transition from Backlog to In progress  - would this work?

Screenshot 2022-10-26 at 09.54.44.png

Trudy Claspill
Community Champion
October 26, 2022

Test it and find out. :)

Alex Magee October 31, 2022

So I still seem to get the wrong error @Trudy Claspill ?

Screenshot 2022-10-31 at 08.47.43.pngScreenshot 2022-10-31 at 08.49.08.pngScreenshot 2022-10-31 at 08.49.57.png

Trudy Claspill
Community Champion
October 31, 2022

Hello @Alex Magee 

The clue is in the error message. You need to properly format the value you are submitting to the Date Started field in the Log Work action.

If you look here: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#--

Under the heading {{[date].[dateformat]}} you will find the functions for formatting date/time values. Find the function that matches the format you need and add that to the smart value you are using in the Date Started field in the Log Work action.

Alex Magee November 6, 2022

Hey @Trudy Claspill , 

So I've now formatted the 'Date Started' field according to the article you posted under {{[date].[dateformat]}}
Screenshot 2022-11-06 at 11.38.17.png

It logs the date and time when it transitions over from 'refined' to 'in progress' status with the workflow also listed below.

Screenshot 2022-11-06 at 11.45.00.pngScreenshot 2022-11-06 at 11.41.21.png


Screenshot 2022-11-06 at 11.41.35.png


But it doesn't seem to process the log time across 'in progress status' to 'done' status with the same error message. 

Screenshot 2022-11-06 at 11.38.11.png

 

Really not sure where I'm going wrong - please help aha :)

 

Cheers, 

Alex

Trudy Claspill
Community Champion
November 6, 2022

Hello Alex,

The format you selected is not correct.

The error message tells you the format you need:

yyyy-MM-dd'T'HH:mm:ss.SSSZ

You need to use the formatting option that matches that.

Alex Magee November 7, 2022

Hey @Trudy Claspill but where do you input this format and what does this look like? And then do you just input this into the log work component or where do this go? Does this need to be edited at all like below? 

Time spent:

{{issue.WorkLog.diff(now).minutes}}m

Date started:

{{issue.LogTime.mediumDateTime}}
Trudy Claspill
Community Champion
November 7, 2022

Hello Alex, 

You are part way there.

The error message has "(started)" at the end. That indicates that the data you are trying to assign to the "started" field (Date Started) is in the wrong format.

You got part way there by changing the smart value you have in the Date Started field. Adding the ".mediumDateTime" function to that does format the data "issue.LogTime", but it is not the correct format. You need one of the other format functions from the reference page.

Alex Magee November 10, 2022

Hey @Trudy Claspill 

So I've now added the format based on the error message but nothing seems to be pulling through now?

Screenshot 2022-11-10 at 12.28.28.pngScreenshot 2022-11-10 at 12.29.37.png

Trudy Claspill
Community Champion
November 10, 2022

The Audit Log shows that you made your configuration change, on Nov 7 and the rule has not been triggered since then. The rule Trigger says it will run when an issue is transitioned from In Progress to Done in the project specified in the Rule Details Scope. Has such an issue transition occurred?

Alex Magee November 14, 2022

Hey @Trudy Claspill

So its now started to track the transitions again but gives the same error :( 

I've now added a custom format which exactly matches the one provided in the error documentation (seen below)

Screenshot 2022-11-14 at 18.11.43.pngScreenshot 2022-11-14 at 18.11.52.png

But the same error occurs (seen below)

Screenshot 2022-11-14 at 18.16.23.png

Trudy Claspill
Community Champion
November 14, 2022

When I created the rule in my own system the jiraDateTime format worked correctly.

What error are you seeing when you used that format option?

Have you added Log actions to your rule to post values to the rule Audit Log to see

- if the value in your LogTime field is what you expect it to be

- what is generated when you use the jiraDateTime format function

Alex Magee November 15, 2022

Hey @Trudy Claspill 

  1. What error are you seeing when you used that format option?
    • The same error (see below)
    • "Invalid date format. Please enter the date in the format "yyyy-MM-dd'T'HH:mm:ss.SSSZ". (started)"
  2. Have you added Log actions to your rule to post values to the rule Audit Log to see
    • I have the following log actions
    • Screenshot 2022-11-15 at 08.44.10.png
  3. If the value in your LogTime field is what you expect it to be
    • So as you can see the LogTime field generates the format below - is this correct?
    • Screenshot 2022-11-15 at 08.45.20.png
  4. What is generated when you use the jiraDateTime format function
    • You mean what is generated in the log? Nothing if so
    • Or if you mean in the LogTime field once I transition to done? Nothing happens


Appreciate your time @Trudy Claspill and your efforts. 

 

Best, 
Alex

Trudy Claspill
Community Champion
November 15, 2022

In your rule add a Log action to print the value of the LogTime field.

Add another rule to print the value you are trying to assign to the Date Started field.

Add those before the Log Work Action.

Show us the Audit Log for an execution of the rule after those changes.

The same rule seems to be working fine for me.

Screen Shot 2022-11-15 at 8.34.35 AM.png

Screen Shot 2022-11-15 at 8.37.47 AM.png

Alex Magee November 16, 2022

 Perfect @Trudy Claspill thank you. I've added a similar flow of rules you posted so Ill post when I have the data on this. On more question though.

 

If the value in your LogTime field is what you expect it to be

  • So as you can see the LogTime field generates the format below - is this correct?
  • Screenshot 2022-11-15 at 08.45.20.png

Many thanks,
Alex

Trudy Claspill
Community Champion
November 16, 2022

"If the value in your LogTime field is what you expect it to be"

I am referring to the LogTime value that you print in your rule Audit Log using the Log action.

Alex Magee November 28, 2022

Hey @Trudy Claspill 

So I've mimicked your exact set-up but again receiving errors again :(
Screenshot 2022-11-28 at 16.53.40.png

 

It still seems to be formatting issues on the date and then the log actions have not been logged ?

 

Screenshot 2022-11-28 at 16.53.55.png

Trudy Claspill
Community Champion
November 28, 2022

(1) indicates that the when this particular rule execution occurred there was no value in the LogTime field for the issues that triggered the issue.

Screen Shot 2022-11-28 at 12.16.39 PM.png

 

When there is no value in that field in the triggering issue, nothing else will work since everything else is based on that field having a valid value. 

Confirm that the issue denoted on the right in the gray box actually has a Log Time value. 

Alex Magee November 29, 2022

Hey @Trudy Claspill 

So it does look like there was a value in the LogTime field but it didn't log it? 

Screenshot 2022-11-29 at 13.37.34.png

 

I've also noticed that it only records tickets that goes straight from 'In progress' to 'Done' as opposed to going through the other status in between. Would it not record otherwise? 

 

Best, 
Alex

Trudy Claspill
Community Champion
November 29, 2022

The other possibility is that you are not referencing the field correctly within the automation.

Have you confirmed that "LogTime" is the correct smart value for that field name?  To check on that, please use this how-to article: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

 

Regarding your question:

"I've also noticed that it only records tickets that goes straight from 'In progress' to 'Done' as opposed to going through the other status in between. Would it not record otherwise? "

I don't understand your question. It only records what? If you are saying that the rule only runs when an issue transitions from "In Progress" to "Closed", well, that is how you configured it in the trigger. If you want it to be triggered by other transitions  you have to change the trigger or copy the rule and use different triggers in each copy. That would depend on exactly which transitions you want to the rule to run for. If you want it to run whenever an issue transitions to Closed regardless of the Status it is transitioning from then clear this field.

Screen Shot 2022-11-29 at 7.51.43 AM.png

However, if you do that then you also need to make sure that the Log Time field is getting filled properly in all cases that might occur before the issue is closed. I would also add a condition after the trigger to check that the Log Time field is not empty, or again you would get errors when the rule runs.

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