How can I store additional value per Jira worklog

Hi all,

I have a customized report that including vendor cost, budget and remaining cost per JIRA worklog. Are there any ways to store the remaining cost per worklog? Need to show left over amount of budget.

For example:

The issue has the custom field name: Approved Amount = 10000 USD

I have a groovy script to calculate the vendor cost = hours * rate

Worklog id 01: vendor cost: 500 USD, remaining cost = 9500 USD

Worklog id 02: vendor cost: 400 USD, remaining cost = 9100 USD

The script for calculation is ready. Just want to know is it possible to store a value per worklog on Tempo or JIRA database.

 

1 answer

0 vote

You can use properties... they're not that flexible in that you can't use JQL query on them unless you write your own JQL function. But they should be fine if you just want to display an additional value or use it in a report.

Sample:

import com.atlassian.core.ofbiz.util.OFBizPropertyUtils
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.worklog.WorklogManager

def worklogManager = ComponentAccessor.getComponent(WorklogManager)
def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject("JRA-1")
def worklogs = worklogManager.getByIssue(issue)

def worklog = worklogs.first()
def propertySet = OFBizPropertyUtils.getPropertySet("Worklog", worklog.id)
propertySet.setDouble("budget", 100)

// retrieving
log.debug propertySet.getDouble("budget")

 

 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

555 views 6 12
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