Groovy help - Transition history store to custom field

Dev JIRA September 17, 2015

Hi All,

I am trying to store the tranistion history details of an issue to a custom field through workflow post-function script.

 

ChangeHistoryManager changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
SearchService searchService = ComponentAccessor.getComponent(SearchService.class);
JiraAuthenticationContext jiraAuthenticationContext = ComponentAccessor.getJiraAuthenticationContext()
changeItems = changeHistoryManager.getAllChangeItems(issue)
def logs = changeItems.findAll{it.getField()=='status'}.each{" ${it.created}; ${it.getFrom()}; ${it.getTo()}\r\n"}

log.warn (logs)

Getting below output while running this script

com.atlassian.jira.issue.changehistory.ChangeHistoryItem@36b22288, com.atlassian.jira.issue.changehistory.ChangeHistoryItem@a9ecae02, com.atlassian.jira.issue.changehistory.ChangeHistoryItem@2ca7697, com.atlassian.jira.issue.changehistory.ChangeHistoryItem@c4b84838]

Could you please suggest how to convert these to exact tranistion history values?

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
JamieA
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 17, 2015
Dev JIRA September 17, 2015

Just tried with changeItems = changeHistoryManager.getAllChangeItems(issue) def logs = changeItems.findAll{it.getField()=='status'}.each{" ${it.created}; ${it.getFrom()}; ${it.getTo()}\r\n"} def test = logs.getFromValue() log.warn (logs) log.warn (test) But still getting error - Caused by: javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.getFromValue() is applicable for argument types: () values: [] Can you please help.

Tomasz Stec
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 17, 2015

Exception speaks right. You try to invoke getFromValue() on ArrayList<ChangeHistoryItem>. Try invoke it on singular element, in this case inside each closure: it.getFromValue()

JamieA
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 17, 2015

+1. Exception speaks right, I like that.

TAGS
AUG Leaders

Atlassian Community Events