Forums

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

Script runner IssuePicker changed are not logged into history

Avi Bachar
Contributor
September 4, 2021

in JIRA UI (Issue View) history everything is OK

but when I am accessing the History Bean in a script I get null in from and too values

although the values are presented in the History list

same code show values of other Custom Fields

any insight on that?

 

This is the Code:

def HistoryOfCurrentIssue = ComponentAccessor.getChangeHistoryManager().getAllChangeItems(issue)
def LastChangeOffIssue = HistoryOfCurrentIssue.listIterator()[HistoryOfCurrentIssue.size()-1]
def StringToOutPut = LastChangeOffIssue.created.toString()+"/"+LastChangeOffIssue.getFroms().values().toString()+"/"+LastChangeOffIssue.getTos().values().toString()+"/"+LastChangeOffIssue.getField()+"/"+LastChangeOffIssue.getUserKey()
return StringToOutPut 

Line 1 & 2 get the last History Bean of the issue (assume an issue is known) 

line 3 - extract the data from the bean and prepare a string to print

line 4 - print the string

This is the Result:

image.png

format is <date>/<from value>/<to value>/<field changed>/<user that made the change>

in this case from value and to value are null

and this is how it shows in the UI

image.png

as you can see from value and to value are not null

1 answer

0 votes
Mohamed Adel
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.
September 4, 2021

Hi @Avi Bachar 

I recommend for you using the following script instead 

import com.atlassian.jira.component.ComponentAccessor

def changedItem = ComponentAccessor.getChangeHistoryManager().getAllChangeItems(issue)?

 this will get all the changes and you can use something like the following to filter out the change date to a specific field 

.findAll {it.field == PRIORITY}?

 

Regards

Mohamed Adel 

Avi Bachar
Contributor
September 5, 2021

Hi @Mohamed Adel 

how this is adding to what I wrote?

I have no problem accessing the log and even get the history item I am interested in (the last one)

the problem is that in JIRA UI I see from value and to value in that item

but when retrieving this item in a groovy script (Scripted Field) I get null in from value and to value.

it happens for change history of Issue Picker - from Script Runner

Suggest an answer

Log in or Sign up to answer