Forums

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

Jira Database Table for Scriptrunner Custom Field

Ryan Lawrence
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!
August 21, 2020

I am trying to find the Jira database table that stores a scriptrunner custom field. We are calculating the time an issue is in one of the statuses of the projects work flow. Below is the script that is running to calculate the amount of time in that status. I have the field in the customfield table but no values are in the customfieldvalue table. 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.history.ChangeItemBean

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()

def inProgressName = "1: Gap Analysis Assessment"

List<Long> rt = [0L]
def changeItems = changeHistoryManager.getChangeItemsForField(issue, "status")
changeItems.reverse().each {ChangeItemBean item ->
def timeDiff = System.currentTimeMillis() - item.created.getTime()
if (item.fromString == inProgressName) {
rt << -timeDiff
}
if (item.toString == inProgressName){
rt << timeDiff
}
}

def total = rt.sum() as Long
if (total == 0) { return null}
else return (total / 1000) as long ?: 0L

1 answer

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2020

There isn't one.  The result from a scripted field is not stored, like a lot of other stuff Jira shows you.

Your question leads me on to something else though.  Why are you asking this?  Why are you looking at the Jira database? 

I ask that because SQL is the single worst possible way to get any information out of Jira, and there is always a better way to do it.  What are you trying to achieve here?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events