Map story points to hours and automatically log work on completion

Problem

  • Our developers prefer to use story points rather than estimating hours for their tasks.

  • Our developers refrain from logging work hours, and we avoid imposing this practice upon them due to our organizational preferences. However, we maintain an interest in knowing the timeframe dedicated to addressing individual issues.

  • We also aim to enforce the usage of Story Points as a Fibonacci sequence.

Let’s see how to perform the above scenarios using Power Scripts™ for Jira - a powerful scripting tool to help automate your Jira.

What These Scripts Do

  • Restrict the Story Points values to 1, 2, 3, 5, 8, 13, or <NULL> and return the error message. Disable the Submit button if there is an invalid value.

  • When the Story Points field is populated with a valid value, check the map to hours and set the Original Estimate and Estimate fields to the associated number of hours. Provide the confirmation message and enable the submit button.

  • When an issue workflow transitions to a Resolved status, the value in the Estimate field is "taken as credit" via work log entry by the user who invoked the transition. The remaining estimate is then depleted.

While mapping Story Points directly to hours isn't considered a strictly agile approach, it's a request that arises frequently that requires offering a solution in certain cases.

Prerequisites

  1. Install Jira Software

  2. Install Power Scripts™ for Jira

  3. Map the Story Points custom field to its customfield ID in the sil.aliases file.

Configure Live Field Listener

This script checks for changes to the story points field and updates the Estimate and Original Estimate fields based on a Story Point to Hours Mapping. Use this script in conjunction with lfExecutor_CreateEstimatesFromStoryPoints.sil and SetWorklogToEstimatedHours.sil.

You should configure this script as a Live Field script for the relevant project.

Script - lfListener_CreateEstimatesFromStoryPoints.sil

if(argv["screen"] == "create" || argv["screen"] == "edit") { lfWatch("storyPoints", {"storyPoints"}, "lfExecutor_CreateEstimateFromStoryPoints.sil" , {"keyup"}); }

Listener References Live Field Executor

This script takes the user's input for the Story Point field on create or edit screens and immediately updates the Estimate and Original Estimate fields based on mapping story points to hours. It also restricts the Story Points field so that only Fibonacci sequences are allowed.

You need to use it in conjunction with lfListener_CreateEstimatesFromStoryPoints.sil and SetWorklogToEstimatedHours.sil.

Script - lfExecutor_CreateEstimateFromStoryPoints.sil

interval timeEstimate; interval timeOriginalEstimate; string errorMsg; if (argv["storyPoints"] != "") { number dataEntered = argv["storyPoints"]; if (dataEntered == 1) { timeEstimate = "2h"; timeOriginalEstimate = "2h"; lfEnable("editSubmit"); lfEnable("transitionSubmit"); lfEnable("createIssueSubmit"); lfEnable("issueCreateSubmit"); } else if (dataEntered == 2) { timeEstimate = "4h"; timeOriginalEstimate = "4h"; lfEnable("editSubmit"); lfEnable("transitionSubmit"); lfEnable("createIssueSubmit"); lfEnable("issueCreateSubmit"); } else if (dataEntered == 3) { timeEstimate = "1d"; timeOriginalEstimate = "1d"; lfEnable("editSubmit"); lfEnable("transitionSubmit"); lfEnable("createIssueSubmit"); lfEnable("issueCreateSubmit"); } else if (dataEntered == 5) { timeEstimate = "2d"; timeOriginalEstimate = "2d"; lfEnable("editSubmit"); lfEnable("transitionSubmit"); lfEnable("createIssueSubmit"); lfEnable("issueCreateSubmit"); } else if (dataEntered == 8) { timeEstimate = "3d"; timeOriginalEstimate = "3d"; lfEnable("editSubmit"); lfEnable("transitionSubmit"); lfEnable("createIssueSubmit"); lfEnable("issueCreateSubmit"); } else if (dataEntered == 13) { timeEstimate = "5d"; timeOriginalEstimate = "5d"; lfEnable("editSubmit"); lfEnable("transitionSubmit"); lfEnable("createIssueSubmit"); lfEnable("issueCreateSubmit"); } else { errorMsg = "Please enter a valid value for Story Points"; lfDisable("editSubmit"); lfDisable("transitionSubmit"); lfDisable("createIssueSubmit"); lfDisable("issueCreateSubmit"); } if (errorMsg != "") { lfShowFieldMessage("storyPoints", errorMsg, "ERROR"); } else { lfSet("estimate", timeEstimate); lfSet("originalEstimate", timeOriginalEstimate); lfShowFieldMessage("storyPoints", "Estimated Hours changed to "+timeEstimate, "INFO"); } }

Configure "Resolved" Workflow Transition Post Function

This script is called from a Workflow Transition Post Function when an issue closes with a successful resolution. It works by taking the value from the Estimated Hours field and using that value to create a work log for the exact amount of time spent by the users who trigger the transition.

This is used in conjunction with lfExecutor_CreateEstimateFromStoryPoints.sil and lfListener_CreateEstimateFromStoryPoints.sil.

In the relevant workflow, you need to configure this script as a SIL™ Post Function when the issue is complete.

Script - SetWorklogToEstimatedHours.sil

addWorklogAdjustEstimate(key, currentUser(), estimate, currentDate(), "automated worklog on successful resolution");