time estimate from a specific date (custom field)

Hi,

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();

    while(alvo_itr.hasNext())
    {
        
        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?

0 vote

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

365 views 0 6
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