time estimate from a specific date (custom field)


I'm trying to develop  a script to get the last value of the field "Remaining estimate" before a specific date (custom field). The script should get the value based on the date of the last log work.

We developed the script below, but we could only get the value of WorkID. Could you help me?


import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
def cont = 0 
def inicio = 0
def log = 0
def date = new Date(01-01-2001)
def ref = getCustomFieldValue("Data de Referência") as Date
def worklogManager = ComponentAccessor.getWorklogManager()
def componentManager = ComponentManager.getInstance()
def changeHistoryManager = componentManager.getChangeHistoryManager()
def alvo = changeHistoryManager.getChangeItemsForField(issue, "WorklogId")
ListIterator alvo_itr = alvo.listIterator();

        cont += 1
        alvo = alvo_itr.next(); 
        result = alvo.getFrom() as Long
        inicio = worklogManager.getById(result).getStartDate() as Date
        criacao = worklogManager.getById(result).getCreated() as Date    
			if (inicio <= ref) {
              if (criacao >= date) { 
			  log = result
			  date = criacao 
return log as String

Thank you

2 answers

@Jamie Echlin [Adaptavist] Can you help us? We need to get the resulting timeestimate the worklogId found?

I don't really understand the question. Worklogs are stored separately from the issue. Remaning estimate is calculated based on the time remaining on subtasks, so to get it at a point in time you would need to know the subtasks as of that time, and their remaining estimate as of that time.

Sorry. Actually, we need to get the "time remaining" value from sub-tasks of a specific date. We need to get to "estimate time" value related to worklogID we got.

As far as I could see, the script is actually returning the correct value, but it seems to be "expected" some sort of update behavior in order for that value to be available for use in other/subsequent context (e.g. in a query)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Feb 07, 2019 in Marketplace Apps

A Timeless Love Story

It started as any story starts, on a normal, rainy day.   Admin meets App, and her name was Klok2, and like any first relationship we were both trying to make it work but neither one knew what...

460 views 8 27
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you