Get changes from issueBundleEvent

I catch issueEventBundle and trying to get changes which happened on the ticket on transition screen(left comment, change priority, etc).
For IssueEvent i can do IssueEvent.getChangeLog, but events from IssueEventBundle hasn’t change log.
I’ve tried this:

ComponentAccessor.getChangeHistoryManager().getAllChangeItems(issue);
ComponentAccessor.getChangeHistoryManager().getChangeItemsForField(issue, "fieldID");
(DelegatingJiraIssueEvent) jiraIssueEvent).asIssueEvent().getChengeLog();

It didn’t help.

Looking for advice

Thanks

2 Likes

I haven’t tried it myself yet, but having a quick look I noticed you have getChengeLog, rather than getChangeLog. Could it be something as simple as a typo?

Also, not all methods in IssueEventBundleFactoryImpl add change log to the events.
The following methods do create IssueEvent with change log:

  • createIssueUpdateEventBundle
  • createWorkflowEventBundle
  • createWorklogEventBundle

While these ones do not contain change log (i.e. it is null):

  • createCommentAddedBundle
  • createCommentEditedBundle
  • createCommentDeletedBundle
  • createIssueArchivingRelatedEventBundle
  • createIssueDeleteEventBundle

So for changing priority I’d expect a non-null change log, but for adding a comment it will be null.

BTW, as a plugin developer, do you have access to Jira source code? If so, you can sniff around IssueEventBundleFactoryImpl for more information.

Let me know if this helps.

Hi @kcichy,
Yes, it’s typo in description, not in code.
In this case i don’t create IssueEventBundle, but catch it.
For case when someone create in Jira custom event and then wrap it into IssueEventBundle and fired it. There is no change log in IssueEvent. Am i properly understand?

For case when someone create in Jira custom event and then wrap it into IssueEventBundle and fired it. There is no change log in IssueEvent.

To be honest I didn’t get this bit. I’ll try to rephrase.

  1. The methods I listed are used by Jira to create IssueEventBundle, which contains Collection<JiraIssueEvent>.
  2. JiraIssueEvent can be transformed to IssueEvent with asIssueEvent().
  3. IssueEvent has method getChangeLog(), which may return a change log, or null if a change log is unavailable.
  4. Change log is available for events such as issue edit or issue transition.
  5. Change log is not available for events such as comment add/edit/delete, issue archive and issue delete.

Is there another way to get this changes, if change log is null?

The easiest way to find out what’s available would be to put a breakpoint inside the DefaultIssueEventBundle constructor.

I put such a breakpoint, performed a comment edit in Jira and I received two events.

The first one is an IssueEvent (wrapped in IssueEventWrapper). In here you get in particular

  • comment, which is the new version of the comment.
  • params, where under "originalcomment" key you can find the old version of the comment (before the edit that’s being saved)
issueEvent = {
  issue = {IssueImpl@57396} "KKK-1"
  user = {DelegatingApplicationUser@57397} "admin(admin)"
  worklog = null
  changeGroup = null
  comment = {CommentImpl@57395} 
  eventTypeId = {Long@57398} 14
  subtasksUpdated = false
  sendMail = true
  redundant = false
  spanningOperation = null
  time = {Date@57399} "Tue Nov 15 23:34:28 AEDT 2022"
  params = {
    eventsource=action, 
    originalcomment=com.atlassian.jira.issue.comments.CommentImpl@d8a53367, 
    baseurl=http://localhost:8090/jira
  }
}

The second one is CommentUpdatedEvent, which contains the same CommentImpl object as the event above (so only the new version).

CommentUpdatedEvent
 comment = {CommentImpl@57395} 

Ok, thanks a lot for your time

1 Like