Hi Atlassian community!
I have the issue, that change-history items do not show froms and tos of text fields like „summary“.
There are changes shown in the issue's change history. But in a script the froms and tos maps are always empty, even for summaries. Changes of fields, which are not free text are showing their changes as expected.
I find no hint for this behaviour in the web. Do you know how to show the changes in a script?
Kind regards,
Andreas
Hi @Andreas
Welcome to the Community!
Did you try getFromString() and getToString() methods instead of getFrom() and getTo()?
They should do the trick.
Dear Tuncay,
thank you! That did work.
Actually I was using getAllChangeItems(issue) which returned a ChangeHistoryItem. This item did not have a fromString or toString.
When I changed to getChangeHistories(issue) I was able to use ChangeItemBeans. They do offer the toString and fromString methods.
:-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm glad it worked. You can use this API method, however, you can also use getAllChangeItems(issue) and ChangeHistoryItem should have getFroms() and getTos() methods in which you will have those changes. The choice is up to you :)
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, I was using getAllChangeItems(). But the getFroms() and getTos() method were both empty maps for free-text fields like summary.
Anyway, your solution worked as expected. Thank you! :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the clarification, I'm glad it helped!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Tuncay Senturk i suspect you are mistaken ChangeHistoryItem didn't have getFromString() or getToString()
At least not in version 9.15.2
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Above I mentioned both, ChangeHistoryItem has getFroms and getTos but if you use getChangeItemBeans()
then you have grtFromString() and getToString()
Here is ChangeItemBean methods
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
life could be so easy if ChangeHistoryItem would just fill fromValues and toValues.
Here is my "workaround" to get the changed values from an event:
ChangeHistoryManager changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
GenericValue changeLogs = event.getChangeLog()
List<ChangeHistoryItem> changedItems = changeHistoryManager.getAllChangeItems(issue).findAll {
it.changeGroupId == changeLogs.id
}
ChangeHistoryItem changeHistoryItem = changedItems.find { it.field == "Story-Punkte" }
List<ChangeItemBean> changeHistories = changeHistoryManager.getChangeItemsForField(issue, "Story-Punkte")
changeHistories.reverseEach {it ->
if (changeHistoryItem.created == it.created) {
log.error("from: " + it.getFromString())
log.error("to: " + it.getToString())
return
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.