Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get historical values from custom field with scriptrunner

Hello,

i am trying to get the historical values of a custom field in scriptrunner. My intend is to find out if and how jira saves these values over time to determine if i can use it in EasyBI to plot the value over time. I didnt had success figuring it out directly in EasyBI.

I have looked at the ChangeHistoryManager but it looks like it only supports Issues not custom fields. 

Any ideas or tips?

Thanks

2 answers

1 accepted

Hi @Eren Dogan ,

 

Please look at an example from the eazyBI documentation page on how to import the field changes registered in a Scriptrunner field into eazyBI - https://docs.eazybi.com/eazybi/data-import/data-from-jira-apps/jira-calculated-and-scripted-custom-fields#Jiracalculatedandscriptedcustomfields-Originalestimatedhourshistory.

The particular example considers the system field "Original estimate". Still, the same concept should apply to custom fields.

 

Best,

Roberts // support@eazybi.com

Hi Robert, 

thanks for your answer, thanks to Antoine i got to look at the values in JIRA/Scriptrunner console. Your suggetions unfortunately, isnt quite what a was looking for.

I added the "Import changes" option in sources with adding some advanced settings (https://docs.eazybi.com/eazybi/data-import/data-from-jira/import-issue-change-history#Importissuechangehistory-Customfielddimensions), but my problem is that the desired field is of type select list single and therefore there aren't any measures findable in regards to change and/or history like with number fields.

Do i have to create a calculated measure to access the change values and if so what be the correct way?

 

Thanks in advance.

Hi @Eren Dogan ,

What type is the custom field in question? The parameters from the eazyBI documentation page you shared will work for the original custom field, if it is a single-value custom field.

Value change won't work with scripted custom fields. For that reasons, they have to be mapped to the Time dimension.

Best,

Roberts // support@eazybi.com

Hi,

The field type is a Select List Single, its used in a project as a drop down menu where three options are available and only one can be selected. The field is not being change by scripts, just by users.

Thanks.

Hi @Eren Dogan ,

In that case, you don't need an additional Scriptrunner custom field to import the change history into eazyBI.

Add the parameters mentioned in the eazyBI documentation page https://docs.eazybi.com/eazybi/data-import/data-from-jira/import-issue-change-history#Importissuechangehistory-Customfielddimensions into your eazyBI advanced settings.

After updating the eazyBI advanced settings, you can select the "Import value changes" option for this custom field together with the "Dimension" and "Property" options. Then, after importing the data, you can create reports displaying the historical information for the custom field.

To see the value change for one specific issue, you can create a report similar to the one below:

Screenshot 2021-12-08 at 10.00.30.png

There you can see the custom field "T-shirt size" value changed from "M" to "XL" in October.

Another option is defining a calculated measure to look for the number of changes to the field. For example, in the case of the custom field "T-shirt size", the calculated measure formula could look similar to the one below:

([Measures].[Transitions to],
[Transition Field].[T-shirt size])

The measure "Transitions to" and the dimension Transition Field are hidden from the view as their potential is fully exposed in calculated measures. With the Issue dimension in rows, you can see the number of changes in the particular field for each issue. See the picture below:

Screenshot 2021-12-08 at 10.04.43.png

The measure also includes issues created with the custom field. So, if a value was changed, the column for the dimension "All" member will have a value greater than one.

Best,

Roberts // support@eazybi.com

Thank you so much, this worked for me.

Like Roberts Čāčus likes this
1 vote
Antoine Berry Community Leader Dec 06, 2021

Hi @Eren Dogan ,

Please see the following snippet that displays the values history of a custom field or a given jira issue : 

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


def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject("JRA-XXX")

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def ch = changeHistoryManager.getChangeHistories(issue)

int count = 1
for(int i=0 ; i <= ch.size() - 1; i++){
for (ChangeItemBean bean:ch.get(i).getChangeItemBeans()){
if (bean.getField() == "Name of your custom field"){
log.info("value " + count + " : " + bean.getToString())
count++
}
}
}

Hope that helps.

Thanks Antoine,

this helped, i got the values i was looking for.

Like Antoine Berry likes this

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you