Forums

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

Why does ChangeHistoryItem not show changes of text fields?

Andreas August 29, 2023

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

1 answer

1 accepted

0 votes
Answer accepted
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 31, 2023 edited

Hi @Andreas 

Welcome to the Community!

Did you try getFromString() and getToString() methods instead of getFrom() and getTo()?

They should do the trick.

Andreas September 4, 2023

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.

:-)

Like Tuncay Senturk likes this
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 4, 2023

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

Andreas September 5, 2023

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! :-)

Like Tuncay Senturk likes this
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 5, 2023

Thanks for the clarification, I'm glad it helped!

Michael Kornatzki
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.
December 12, 2024 edited

@Tuncay Senturk i suspect you are mistaken ChangeHistoryItem didn't have getFromString() or getToString()

At least not in version 9.15.2

Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 13, 2024

Hi @Michael Kornatzki 

Above I mentioned both, ChangeHistoryItem has getFroms and getTos but if you use getChangeItemBeans()  then you have grtFromString() and getToString() 

Here is ChangeItemBean methods

 

Michael Kornatzki
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.
December 13, 2024

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
}
}

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

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 Now
AUG Leaders

Atlassian Community Events