Forums

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

Logging time spent based on issue status with automation rule

Meital Adir
Contributor
June 10, 2021

Hello,

I would like to update time spent on issue with automation rule, 

based on the issue status:

If the status is "In progress" time spent should be 50% from the original estimate 

and if the status is Done - 100% of original estimate. 

I've tried the following in advanced edit issue action: 


{
"update": {
"worklog" : [
{
"add": {
"timeSpent" : "{{issue.fields.originalEstimate.divide(2)}}d"
}
}
]
}
}

and got this error: (Invalid time duration entered. (worklog_timeLogged))

Any idea how to use smart value/JSON for this use case?

Thanks

1 answer

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.
June 10, 2021

Hi @Meital Adir 

What problem are you trying to solve by doing this?

People use Jira work logging to record the actual time working on an issue.  That actual time can be later compared to original estimates for various purposes.

If you are just recording the time based upon status transitions, it seems like you are using the feature as a percent complete indicator, or as something like "standard task times" for billing only.

Best regards,

Bill

Meital Adir
Contributor
June 24, 2021

Hi, 

I'm looking for a way to use it as  a percent complete indicator to present it in a report. The team will not record the actual time working so I'm looking for a way to automate it and create a report.

Thanks

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.
June 24, 2021

Hi @Meital Adir 

It looks like your update JSON looks correct (other than that stray "d" character), and the smart value for original estimate is the error.  Please try {{issue.timeoriginalestimate}} for single issues or for issues which have children try {{issue.aggregatetimeoriginalestimate}}

One challenge with automation if learning the correct smart value for a field.  This how-to article shows a technique to find the smart values when you are unsure:

https://support.atlassian.com/jira-software-cloud/docs/find-the-smart-value-for-a-field/

__Bill

Meital Adir
Contributor
June 24, 2021

Thanks @Bill Sheboy

Actually I've been trying a few hours and the issue now is how to divide the original estimate into half - in order to log work that is 50% from the remaining estimate. 

I'm using smart value for the log work action:

(we're estimating in days) 

{{#=}} {{issue.original estimate}}*0.5 /14400{{/}}

The problem is that I get the total number of days (same as remaining/original) and not half of it as I need. 

I've tried also this {{#=}} {{issue.original estimate.divide(2)}} /14400{{/}} or {{#=}} {{issue.original estimate.sum}}*0.5 /14400{{/}} (also without /14400) and I keep getting the same estimate value and not half of it. 

can you tell what's wrong in the formula?

 

Thanks,

Meital

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.
June 24, 2021

The .divide(2) will definitely work, and I suggest you check your site settings for the  definition of working day to see if that is the problem with what you are seeing.

When you enter values in original estimate, the working day is used; it isn't a raw number...no matter how you enter it.

For example, my work-day set up is Monday-Friday and 8 hours long.  If I enter 40h in original estimate, it converts that to 1w for display but stores 144000 seconds.  If I had entered a value like 1w 3d, it would use working days and hours to convert that to 230400 seconds.

My suggestion is to confirm your working days and hours, and divide the seconds amount to get days, and then divide that by 2.

Meital Adir
Contributor
June 24, 2021

thanks for the quick response @Bill Sheboy , our settings of working days and hours are the same - 8 hours a day, 5 days a week. and I still get the same number, seems like I can't divide that by 2 :(

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.
June 24, 2021

That's curious.  If you write the value to the audit log, what value do you see?

When I did this, the division worked: {{issue.Original estimate.divide(2)}}

Meital Adir
Contributor
June 25, 2021

I get the value of the original estimate - for 1d in original estimate I got 14400 in the audit log. here is the rule 

time spent.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.
June 25, 2021

Please try removing the math operators and just use the smart value, divided by 2.  That worked for me.

Meital Adir
Contributor
June 25, 2021

Now it's working for me when I use hours and change the default time tracking settings to hours. This is the value I used: {{#=}}{{issue.original estimate.divide(3600)}} /2 {{/}}

Thanks Bill!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events