Jira Automation: Convert Time Tracking into number in custom field, add validator time and divide
Asked by javier.espinosa:

**Using:**Jira Software Cloud Version

**Current Scenario** : We track time spent in development (++Time Tracking++ ) and time spent validating/testing (++Validator Time++ ). We use the "++Time tracking++ " issue field and a custom "**Validator** **Time** " number field. The team knows that the "++Validator Time++" must be entered in a specific format (e.g.: (1, 1.25, 1.5, 1.75, 2, etc.)

**Current Need** : We want to add the ++Time Tracking++ + ++Validator Time++ and then convert it into Story Point by dividing by 4. (4hrs = 1 Story Point)

**Performed** : Created an automation Rule that when issues are transitioned from "In Progress" to "Done" it set the ++Time Tracking++ to 0, then the custom field ++Tracking Time++ pulls ++Time Tracking++ and divides by 3600 and stores it. Then it Validates that the "++Validator Time++ " is Greater than zero and "Tracking Time" is great than zero. Finally, if both previous conditions are true it pulls the "++Tracking Time++" divides by 4 and adds "Validator Time divided by 4".

**Problem** : When I move an issue from "In Progress" to "Done" and "++Time Tracking++" has minutes e.g.: (15m, 30m, 45m, 1h 15m, 1h 30m, 1h 45m, etc.) The Tracking Time result is zero when it should be 0.25, 0.5, 0.75, 1.25, 1.5, 1.75)

**Below: The formulas and transitions**

1. Issue transitioned:

In Progress to Done

2. Edit Issue:

Tracking Time: {{issue.field\|0}}

3. Edit Issue:

Tracking Time: {{issue.timetracking.timeSpentSeconds.divide(3600)}}

4. Branch Rule/Related issues:

**Type** : Current issue, **Restricted:** Playground project

5. Issue Field condition:

Validator Time greater than 0

6. Issue Field condition:

Tracking Time greater than 0

7. Edit issue:

Actual Points: {{#=}}{{issue.Tracking Time.divide(4).round}}+{{issue.Validator Time.divide(4).round}}{{/}}

**Note**: I'm new to Jira automation.

**Help** **needed**: How can I get this to convert time tracking add it against validator time and divide the total by 4 to get Actual Story Points.


Answers:
author: Bill Sheboy
body: Hi [@javier.espinosa](/t5/user/viewprofilepage/user-id/4062746)

I am unclear why you are trying to calculate story points, usually an abstract relative measure, with a formula. Why not just talk to the team about using time-based estimation? Regardless of that question...

It appears you are updating your Tracking Time custom field within the rule and then trying to use the new value in the same rule later. When you want to do that, you need to add an action for Re-fetch to load new values from storage. Please note this will slow down your rule significantly.

Best regards,

Bill

comments: author: javier.espinosa
body: Thank you Bill for taking the time to respond to my question.

<br />

We estimate in Story Points and wanted to get Actual Story Points from the actual time spent (both Time Tracking + Validator Time). Thus having both Estimated Story Points and Actual Story Points. This would allow observing the variance of the issue between the Estimate and Actuals.  

I made this short 10min video where I share my screen and and walk thru my situation. I would appreciate if you could check this out and advise.

<br />

<https://www.awesomescreenshot.com/video/3217486?key=d228897843853f94a4d98e6c6c2a04c6>

<br />

<br />

Also inserted a screenshot of the rule. I not sure how to add a re-fetch of the new value and where to place it in the rule.

![Screen Shot 2021-03-30 at 9.42.48 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/136590i7B73A5A963A0F807/image-size/large?v=v2&px=999 "Screen Shot 2021-03-30 at 9.42.48 AM.png")

Cheers,

Javier


author: Bill Sheboy
body: Hi [@javier.espinosa](/t5/user/viewprofilepage/user-id/4062746)

Thanks for the image of the rule; that helps quite a bit when trying to diagnose automation symptoms. Let me try to explain about my Re-fetch suggestion:

* When an automation rule triggers, the data in any issues used is up to date at the point it time they are gathered
* My understanding is: If the rule edits the issue, the edits are saved to storage...However, they do not yet impact the values the rule knows about in memory. Those are still the values from the original load.
* If you want the changed fields to be accessible to the rule, [the issue needs to be Re-fetched from storage](https://support.atlassian.com/jira-software-cloud/docs/automation-actions/#Automationactions-Re-fetchissuedata)

In your rule, you edit Tracking Time twice and then use it to edit the New Actual Points. I suggest that:

* You consider if you can edit Tracking Time with one edit, and then add a Re-fetch action after that edit
* If you cannot combine the two edits of Tracking Time, you would need to add a Re-fetch action after each edit


author: javier.espinosa
body: Bill,

Thank you very much for your support and for explaining how to use the re-fetch function/action.

I made significant changes and combined with the re-fetch it works great. Explaining what I did incase someone else wants to do this.

Goal: Be able to compare Estimated Story Points with Actual Story Points.

Created following custom fields and its purpose:

**++Time Tracking Conversion++:** Pull ++Time tracking++ and store it in seconds

**Tracking Time:** Pull ++TimeTracking Conversion++ and store it in hours

**Validator Time:** Number field for the tester to enter their time spent in testing/validation

**New Actual Points:** divide by 4 to convert hours into story points.

**Actual Story Points:** use .ceil to round up.

**Story Point Variance:** subtracts Story Points minus Actual Story Points

**Note**: re-fetch action makes this rule work.

**Automation formulas used:**

{{issue.timetracking.timeSpentSeconds}}

{{#=}}{{TimeTracking Conversion}}\*0.0002778{{/}}

{{#=}}{{issue.Tracking Time.divide(4)}}+{{issue.Validator Time.divide(4)}}{{/}}

{{issue.New Actual Points.ceil}}

**Below an image of the Automation rule.**

![Screen Shot 2021-03-31 at 6.30.25 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/136966i36DFCB8C2AE97294/image-size/large?v=v2&px=999 "Screen Shot 2021-03-31 at 6.30.25 PM.png")![Screen Shot 2021-03-31 at 6.31.01 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/136967i2EB5FDC89BE70CF4/image-size/large?v=v2&px=999 "Screen Shot 2021-03-31 at 6.31.01 PM.png")

Thank you very much Bill for your advice. I hope for someday to be great in Jira as you to be able to help you and return the favor. Thanks

Cheers

Javier Espinosa