Summary
I am beginning to log time spent on our support tickets using Jira Service Desk and Automation for Jira. I have taken a look at the existing plugin for our billing app "Harvest" and the functionality is sub par for our needs, so I've decided to automate the recording of timepent, however, I am getting an error "AS-6558 (Invalid time duration entered. (worklog_timeLogged))." in the second automation rule.
Logic of Automation Rules
Rule 1: When ticket is transitioned from any status to "In progress", I have a field (only available on the edit screen) called "Timestamp_for_billing", I set the timestamp to {{now}} which records the timestamp the user begins working on this issue.
Rule 2: When the ticket is transitioned from "In Progress" to any other status, I have an automation rule with the following logic that is throwing the error mentioned the summary above.
{
"update": {
"worklog" : [
{
"add": {
"timeSpent" : "{{now.diff(issue.Timestamp_for_billing).minutes}}m"
}
}
]
}
}
Any ideas of what I am doing wrong, or if anyone has a better way to do this, I am open to suggestions.
Thanks in advance!!
Per suggestion above, In the case of your smart value, can you try swapping the positions of now and issue.Timestamp_for_billing to see if that makes a difference." fixed the issue.
Can you post the full working code for this please? There are a few combinations of which way that can go and it would be great to see this working as I'm trying to do exactly the same thing as you.
Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have two automation rules
Rule 1. - adds the now timestamp when the issue is triggered to "in progress"
Rule 2 - does the calculation to add to time spent. One thing I want to note is the last edit action (which will also clear out the value in timestamp for billing) so you don't get accidental calculations
{
"update": {
"worklog" : [
{
"add": {
"timeSpent" : "{{issue.Timestamp_for_billing.diff(now).minutes}}m"
}
}
]
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks mate, really appreciate this. Especially the response, life saver!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you have JIRA Workflow Toolbox, You could find the complete guide here:
https://apps.decadis.net/display/JWT/Automatic+work+log+with+start+and+stop+work+transitions
If you have to do it with automation for JIRA, please explain it more and say what's worklog_timeLogged field type and where and how you set it?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ansar, thanks for the tip, I don't have JIRA Workflow Toolbox, and was able to accomplish this in Automation for JIRA.
worklog_timeLogged is a default field in JIRA and is used for time tracking. I found references on how to update these fields from the automation for jira documentation: https://docs.automationforjira.com/issues/edit-additional-fields.html#field-syntax-examples
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I did some additional troubleshooting by having Automation for Jira return the value from
{{now.diff(issue.Timestamp_for_billing).minutes}
To return the value in a free text field to see what it was spitting out, and the value returned was "-20"
What am I doing wrong here, it should return a positive value.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jeffrey,
Thee easiest way to test and fine tune your smart values is to use the Log action which will output the value to the audit log.
In the case of your smart value, can you try swapping the positions of now and issue.Timestamp_for_billing to see if that makes a difference.
Finally, you can use the Log work action to add timeSpent and that will be much easier than using the Edit action.
Cheers,
Simeon.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Simmo thanks for the tip about using the log action (good to know for the future).
Yes, swapping the positions of the now and "issue.Timestamp_for_billing " did the trick, I didn't think that would work when I originally thought of that idea. Silly me, I should have tested it anyway.
Thanks for the tip and I am now up and running.
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.