Hi Everyone,
I am writing a Listener which needs to capture the event(s) when the custom field ("Epic Link" from JIRA AGILE) of the issue is updated.
@EventListener public void onIssueEvent(IssueEvent issueEvent) { }
I have following questions
Please advice me if we can take any of the the above approach or if there is a better way to capture the custom field update event.
Thanks in advance.
Cheers,
Ankit
1. Yes, an event is fired on every occaision a field is changed, but you'll need to trap several
2. No. Events are fired by things that happen to issues, not fields
2 is the whole point of events, they are issue changes. A field could be changed on create issue (from null to something), issue edit, during a transition, and some can change as a result of other actions.
Different actions on issues fire different events, but they may well have similar field changes.
So, what you need to do is write a listener that will catch most events that might contain a field update, and then read the contet of the change to see if the field has changed (then if it has, do your logic)
Hi Nic,
Thank you for quick response. I am not sure how to "write a listener that will catch most events".
If I change my listener code to the following will it be able to capture most of the events?
If not then will you be able to provide me with some code example.
@EventListener public void onIssueEvent(AbstractEvent abstractEvent) { }
Thanks,
Ankit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic,
I changed my listener to following to test that I am able to capture the event fired when the custom field("Epic Link" from JIRA AGILE) is changed.
@EventListener public void onEvent(AbstractEvent event) { }
But I am not able to catch the event fired on change of custom field value. Though I am able to catch the event when the non-custom fields are updated. I think I am missing something obvious.
Thanks,
Ankit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Again, events are fired by ISSUE changes. When you change a field, that's an issue updated or one of the transition events.
When you change the ISSUE, events are fired. You need to catch them
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic,
As per your comment
Again, events are fired by ISSUE changes. When you change a field, that's an issue updated or one of the transition events.
Let say event X is fired when a custom field for an issue is changed.
Event X can be
If I use the following code
@EventListener public void onEvent(AbstractEvent abstractEvent) { }
It should capture all the events including event X as per your previous comment.
That will capture all events. You might want to code it to ignore some Events, rather than run code that looks for a change of your field every time, but you don't really have to. As an example, I would consider ignoring issue delete, comment update and delete, and so on. Events where your field cannot change...
But I am not able to catch event X using the above code. Though I can capture "1. issue updated event" and "2. transition events", which means event X is "3. some other event".
Also it means that the event X is not of AbstractEvent type, that is why I am not able to catch it, which confuses me.
How do I catch event X?
The above code does not work :(
What is wronge here? Why am I not able to catch event X?
Thanks,
Ankit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>Let say event X is fired when a custom field for an issue is changed.
For the third time, and I'm running out of ways to say it.
Events are fired by ISSUE changes. When you change an issue (maybe changing your custom field), you could get event X, Y or Z depending on your configuration.
Could we step back from this and look at the actual listener code though. What do you have for overriding workflowEvent(IssueEvent event) ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
public class PluginListener implements IssueEventListener { @Override public void workflowEvent(IssueEvent issueEvent) { Long eventTypeId = issueEvent.getEventTypeId(); Issue issue = issueEvent.getIssue(); if(eventTypeId.equals(EventType.ISSUE_CREATED_ID){ createIssue(issueEvent); } else if (eventTypeId.equals(EventType.ISSUE_DELETED_ID) ) { deleteIssue(issueEvent); } else { updateIssue(issueEvent); } } }
Thank you NIC for your patience.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ankit,
I do realise that the post is way too old. But did you happen to find a way around this issue?
I have stumbled upon the same issue, when no event is being fired if a custom field(in my case, "Issue Cause") is updated.
Any help /guidance is appreciated.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm looking for some help/guidance here as well. I need to catch when the "End Date" field is updated and populated the custom field "Previous End Date" with the old value.
So if the End Date is 2/15 and I change it to 2/20, "Previous End Date" = 2/15 and "End Date" = 2/20.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.