It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Automation for Jira: Logging Time Spent with Automation Rules Edited

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!!

3 answers

1 accepted

0 votes
Answer accepted

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.

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? 

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

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. 

Simeon Ross Atlassian Team Jan 05, 2020

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.

@Simeon Ross 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. 

Simeon Ross Atlassian Team Jan 06, 2020

No worries, glad you're all sorted!

Suggest an answer

Log in or Sign up to answer
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