This is a Script Field that shows a table with all statuses that the issue has been and the time it has been in, expressed in seconds. The mapping between status and it’s Lozenge is done “manually” throught it’s ID on the function colorCategory.

The code contains HTML tags so I attach the GitHub link to avoid visual problems -> Time in Status

You need to add the Custom Field created on a View Screen and the result will be something like the image.

Posted by:eloii23

8 replies on “Script Field – Time in Status

  1. Hello,

    This is very useful in my opinion but I have 2 doubts.

    1) The status time can be in format hours:minutes?
    2) When the issue passthrough 2 times from the same status, the time is sum in one status or shows 2 times?
    Best regards,

    Like

    1. Hi Juanjo!
      1) Yes, the time format is improvable but was not the focus of the logic so you can express it as you need it.
      2) When the issue passthrough 2 times from the same status it will appear 2 times on the table, because the table rows are extracted from Issue History entries, and it will be 2 different entries for each status.

      Hope this helps,
      Regards!

      Like

      1. Hello,
        I will try to set this modifications in the code and give you feedback.
        Good job!
        Best regards.

        Like

  2. The following code shows you the time in format hh mm instead of seconds

    def hoursRest = (TimeSpent/ (3600))
    def hours = hoursRest as Integer
    def minutesRest = ((TimeSpent % 3600)/60)
    def minutes = minutesRest as Integer
    valueToShow = ” ” + (hours as Integer).toString() +”h “+ (minutes as Integer).toString() + “m”

    Liked by 1 person

    1. Thanks for your Job!
      I’ve updated the repository with usage of your code to fromatting the time in Status.

      Regards!

      Like

      1. Hi,

        Thanks for your reply but it did not work. I’ve encountered issue while using this code
        def user = changeItems[i].getUserKey()

        Error message:
        [Static type checking] -Cannot find matching method
        com.atlassian.jira.issue.history.ChangeItemBean#getUserKey(). Please check if the declard type is correct and if the method exists.

        Added in the code

        if (i == 0){
        status1Time = item.created.getTime() – issue.getCreated().getTime()
        statusCategory = colorCategory(statusManager.getStatus(item.getFrom()).getStatusCategory().getId())
        statusCategoryTo = colorCategory(statusManager.getStatus(item.getTo()).getStatusCategory().getId())
        String timeInStatus1 = formatTime(((status1Time / 1000) as long ?: 0L))
        def user = changeItems[i].getUserKey()

        Regards,
        Rod

        Like

Leave a comment