It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to send a mail with script listener, when customfield value has changed? Edited

Hello I need to send a mail, when a customfield ("Group") gets changed. I already got the following, which gets processed without any ERROR but no mail is sent. Am I missing something?

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption;

if (event.getChangeLog().getRelated('ChildChangeItem').find { it.field == ("Group") } ) {

ComponentAccessor.issueEventManager.dispatchEvent(10000L, event.issue, event.user, true)


}

 

EDIT: We also use Email This Issue and in the specific project we run this script listener, we already configured a mail template and a context / notifications with the given event (10000).

1 answer

Hello

1) Try to enable logging for your listener and check what is worng.
Below is an example how to enable logs:


import org.apache.log4j.Category;
log.setLevel(org.apache.log4j.Level.INFO)
log.info("start logging ....");


2)Try dispatchEvent(IssueEventBundle) method
From Jira API https://docs.atlassian.com/software/jira/docs/api/8.1.0/
...
dispatchEvent(IssueEventBundle issueEventBundle)
Dispatches a bundle of issue events.
...
dispatchEvent(Long eventTypeId, Issue issue, ApplicationUser remoteUser, Comment comment, Worklog worklog, org.ofbiz.core.entity.GenericValue changelog)
Deprecated.
since v6.4.10, please use dispatchEvent(IssueEventBundle).

Thanks for your response,

how dos this method work? I mean what should be standing inside the brackets "()" to dispatch that specific event "10000". I don't code very much, so I don't really know what parameter (IssueEventBundle issueEventBundle) is.

Hi

As you can see from description, you can get IssueEventBundle from IssueEventBundleFactory interface

Check this topic https://community.atlassian.com/t5/Jira-questions/Is-it-technically-possible-to-fire-an-event-without-updating-an/qaq-p/317043

Ok thanks alot,

it worked somehow, and with logging, i can now se that all my code gets processed. The problem now is, there is still no email sent. Am I still missing something? I mean, event gets fired, I created a "Notification" for that event and a "Template" in Jira Email this Issue.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

303 views 1 3
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you