Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,359,955
Community Members
 
Community Events
168
Community Groups

Get event type- script listener

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

2 votes
Answer accepted

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) 

Hi @Mark Markov , Thanks!

The output is 

Issue Updated

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

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

}

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Online AMA this week: Your project management questions answered by Jira Design Lead James Rotanson

We know that great teams require amazing project management chops. It's no surprise that great teams who use Jira have strong project managers, effective workflows, and secrets that bring planning ...

179 views 1 6
Read article

Atlassian Community Events