Get event type- script listener

Dan27
Contributor
July 30, 2018

Hello,

I would like to create a script listener.

In the start of the code, I would like to put a condition that sends true only if the specific event was updating the 'fix version' system field.

How can I find the type of the event= which field was updated and triggered this script listener.

 

Thanks for your help :)

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
2 votes
Answer accepted
Mark Markov
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.
July 30, 2018

Hello @Dan27

You could find event type via evenTypeManager

Here is example:

import com.atlassian.jira.component.ComponentAccessor


def eventTypeManager = ComponentAccessor.getEventTypeManager()
def eventTypeName = eventTypeManager.getEventType(event.eventTypeId).getName()
log.error("EVENT TYPE NAME --> "+ eventTypeName) 
Dan27
Contributor
July 30, 2018

Hi @Mark Markov , Thanks!

The output is 

Issue Updated

 I would like to get the field that was updated, in my case- 'Fix Version'

Mark Markov
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.
July 30, 2018

Than you ll need to listen for field changes on issue_updated event, not events itself

Here is example



def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "Fix Version"}
if (change) {
log.error "Value changed from ${change.oldstring} to ${change.newstring}"
// your actions if the field has changed

}
Dan27
Contributor
July 31, 2018

Thanks!

TAGS
AUG Leaders

Atlassian Community Events