Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Profields script field - time spent for a specific project

Amílcar Rodrigues
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 20, 2019 edited

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]
Atlassian Partner
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
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
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]
Atlassian Partner
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
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 22, 2019 edited

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 Champion
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
TAGS
atlassian, likes for trees, atlassian community, social impact, tree planting campaign, community kudos, atlassian giving, environmental impact, sustainability, likes for good, atlassian social responsibility, community challenge

Make every click count—help us plant 50,000 trees! 🌳

Want to make your everyday Community actions directly contribute to reforestation? The Atlassian Community can achieve this goal by liking a post, attending an ACE, sending your peers kudos, and so much more!

Help us plant more trees
AUG Leaders

Atlassian Community Events