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

This widget could not be displayed.

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

This widget could not be displayed.

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 Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

428 views 3 17
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