Is it possible to get the data (assignee, time spent) in Work Log JIRA using ScriptRunner

I want to calculate summary the cost rate of each assignee and his time spent on the same issue. Is it possible to do that using groovy script and WorklogManager.

For example:

My rate is $100/hour and another is $150$/hour. We logged work on the same issue. I logged 2 hour and he logged 3 hour. The summary cost for this issue should be: $650.

1 answer

This widget could not be displayed.

Script Runner for JIRA is all about handling issues, so things like worklogs and assignees are always readily available.

For your cost rate stuff, you'll need to do a bit of coding in SR and possibly write add-ons to help with reporting though.  You'll need to decide where you are storing the rates and define how to get to them, then you'll need to think about how you want to get out that $650.  At the most simple level a script-runner scripted field could easily read all the worklogs for time and assignee, mulitply it with a (hard-coded) rate and accumulate them all together, dumping the total on screen, but I suspect you might want more from it than that?

 

Hi Nic,

Thank you for your answer. I put the rate into Scripted field and I'm able to get that value. But the issue is I don't know how to get the data from Work Log (get assignee and their time spent). I have tried to find on google but no luck. Could you please give me a code example how to do that.

Thanks in advance.

A scripted field has direct access to the issue, so

issue.getAssignee() will return the current assignee

For the worklogs, there may be a better way to do it in a script, but I've used

worklogManager.getByIssue(issue)

to fetch the list of worklogs.  You can then iterate over that list using worklog.getAuthor() and worklog.getTimeSpent() to get the owners and numbers out.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

76 views 1 0
Join discussion

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