The following article shows how to add script field in right issue column view under Time Tracking section.

For this example, will be necessary:

  1. Create a new script field with the information that we can display.
  2. Create a new section in the right context below Time Tracking.
  3. Add the script field created to the new section created.

Let’s go to it

CREATE SCRIPT FIELD

In this example, the information of this field will be worklog of the current issue with the sum of all the worklog saved in related issues only for a issue type “Rework”.

Go to script fields and create a new Script field.

Field Name: Aggregate time spent

Template: Duration (time-tracking)

Script:

The following link contains the code of ScriptField
https://github.com/MrAddon/Blog_Examples/blob/master/JJ_ScriptField.groovy

In this point, the most important is return the value as Long because Time Spent works with Long values. If you want to apply the template Duration (time-tracking) you need Long value.

Now, if you add the scriptfield to some screen and this issue has related issues type “Rework” with logged time, this field will appear dates section.

But, we want to see this information in right section (Time Tracking) because this is time logged and it is interesting compare it with all logged information.

CREATE A NEW SECTION

Go to Fragments and create a Script Fragment “Show a web panel”

Note: Show new section Time Tracking

Location: atl.jira.view.issue.right.context

Key: aggregate-time-spent

Menu text: Time Tracking (extra information)

Weight: 100

Condition: Nothing for testing, in production you should add query for condition.

ADD SCRIPT FIELD

Provided class/script

The following link contains the previous code for the web panel
https://github.com/MrAddon/Blog_Examples/blob/master/JJ_WebPanel.groovy

TimeHHMM convert the Long (standard time spend format) to HHMM, this function is necessary because we are going to show a HTML table. If you don’t use this function, the field will be shown in seconds.

Also, the information will be shown inside a HTML table shows it with a better format, this is optional, you can show the variable without HTML table.

 

I hope it’s helpful

 

Posted by:juanjomarchal

Leave a comment