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)."
Hello @Alex Magee ,
I think its the issue with smart values. Please check this.
https://www.youtube.com/watch?v=XnGxc7C3hZc
Cheers!
I also tried your video but doesn't seem to work also?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Alex Magee -- Welcome to the Atlassian Community!
I believe both your smart values and the time logging have some issues...
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You would need to add a Post Function to the workflow transition to set the field value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Trudy Claspill ,
So I've now formatted the 'Date Started' field according to the article you posted under {{[date].[dateformat]}}
It logs the date and time when it transitions over from 'refined' to 'in progress' status with the workflow also listed below.
But it doesn't seem to process the log time across 'in progress status' to 'done' status with the same error message.
Really not sure where I'm going wrong - please help aha :)
Cheers,
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Trudy Claspill
So I've now added the format based on the error message but nothing seems to be pulling through now?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
But the same error occurs (seen below)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Trudy Claspill
Appreciate your time @Trudy Claspill and your efforts.
Best,
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Many thanks,
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Trudy Claspill
So I've mimicked your exact set-up but again receiving errors again :(
It still seems to be formatting issues on the date and then the log actions have not been logged ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
(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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Trudy Claspill
So it does look like there was a value in the LogTime field but it didn't log it?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
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.