Profields script field - time spent for a specific project

Amílcar Rodrigues March 20, 2019

Hello,

 

How can I get the time spent (the sum of all issues) for a specific project, using script fields?

The documentation uses hard-coded filters like project's key or issue's status, as you can see at ( https://confluence.deiser.com/display/PROFIELDS49/Script+Examples ), and my doubt is how can I dynamically access these information in order to create a script field and use it as a column at Project Navigator screen, as displayed at ( https://www.deiser.com/profields ), like in that first picture, which probably uses the project time spent for the relative row, to display it at column "Spends".

 

Any hint?

 

Thanks,

1 answer

1 accepted

0 votes
Answer accepted
Capi [resolution]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
March 20, 2019

Hi @Amílcar Rodrigues,

If what you need is the sum of the values of all issues in your project, you don't need to script anything. Just use a summative field and what the origin issue custom field is.

You can see the full instructions here, I think the example is exactly what you're trying to do.

Screen Shot 2017-08-15 at 20.59.08.png

If what you need is more elaborate, feel free to raise a ticket!

Dan Florea March 20, 2019

Thanks Jaime !

I work with Amilcar - and I was able to obtain Original Estimate, Time Spent, Remaining Estimate as cumulative values for projects - which is really cool !

We would like to get to the next level :-) and calculate some combined values:

Estimate at Completion (EaC) = Time Spent + Remaining Estimate.

Also Overrun% = [Time Spent + Remaining Estimate - Original Estimate] / Original Estimate

I guess it will not be as easy, and for this we will need script fields?

Thank you for your help!

Capi [resolution]
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
March 21, 2019

Hi @Dan Florea !

Glad I was able to help. Yes, you'll need script fields for the remaining values you want to calculate. 

Unfortunately scripting is beyond my skillset, but a colleague might be able to help. If you raise a ticket, we can support you over there.

Amílcar Rodrigues March 22, 2019

Hello @Capi [resolution]

 

Thank you for feeding this thread. @Dan Florea and me worked around this.

Basically, the data required above, you can retrieve it from each project's issues.

You get specific project's issues like that:

def projectId = project.getId()
def issueIds = issueManager.getIssueIdsForProject(projectId)
def issues = issueManager.getIssueObjects(issueIds)

You have "issues" like a collection. All you need is to iterate over it, use inherited methods to get information, and store them in another proper data structure (e.g. ArrayList), like:

def originalEstimateList = new ArrayList<Long>()
def timeSpentList = new ArrayList<Long>()
def remainingEstimateList = new ArrayList<Long>()

issues
.each {
originalEstimateList.add(it.getOriginalEstimate())
timeSpentList.add(it.getTimeSpent())
remainingEstimateList.add(it.getEstimate())
}

 No need of any import. All you need is already there, just copy and paste.

 

Reference: https://docs.atlassian.com/software/jira/docs/api/7.6.0/overview-summary.html

Leo Diaz _ DEISER
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 2, 2022

Hi @Amílcar Rodrigues @Dan Florea and @Capi [resolution] 

Just to inform you, we have published these examples in our documentation:

Also, we have included new examples in our documentation.

I hope it helps you!

Leo

Like Amílcar Rodrigues likes this

Suggest an answer

Log in or Sign up to answer