Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,464,552
Community Members
 
Community Events
176
Community Groups

How to generate notification for IssueLinkCreatedEvent ?

The event IssueLinkCreatedEvent is available within the listener "Send a custom email (non-issue events)" but I can't send a notification to the watchers of the link issues.

The event IssueLinkCreatedEvent is not available within the listener "Send a custom email" where I could simply send a notification to related issues watchers.\

 

I thought about creating a "Custom listener" that would generate a "GenericEvent" on "IssueLinkCreatedEvent". Then, a listener "Send a custom email" would send the email.

Can I create a GenericEvent programatically? What other options do I have?

Thanks

 

2 answers

Hi @Vincent Peres , I didn't test it but IssueLinkCreatedEvent object has method getIssueLink . It returs a com.atlassian.jira.issue.link.IssueLink object and it contains reference to the source and destination issues (getSourceObject(),  getDestinationObject()).

So you can get watchers from the linked issues.

0 votes

The issueLinkCreatedEvent won't have an issue object to act on. So the built-in Send Email script won't know which email to send email to.

Your options are either, use the custom scripted listener to send the email:

import com.atlassian.mail.server.SMTPMailServer
import com.atlassian.mail.server.MailServerManager
import com.atlassian.mail.Email
import com.atlassian.mail.MailException
import com.atlassian.mail.MailFactory
import com.atlassian.mail.queue.SingleMailQueueItem
import com.atlassian.jira.component.ComponentAccessor

def recipients = 'xxx@yyy'
def subject = 'whatever subject you want'
def body = 'contruct your own body'
def plain = true //or false if you want to include html in body

def mailServerManager = ComponentAccessor.mailServerManager
def mailServer = mailServerManager.defaultSMTPMailServer

if (mailServer && !MailFactory.settings.sendingDisabled) {
def email = new Email(recipients)
email.setFrom(mailServer.defaultFrom)
email.setSubject(subject)
if(plain) {
email.setMimeType("text/plain")
} else {
email.setMimeType("text/html")
}
email.setBody(msgBody)
try {
def item = new SingleMailQueueItem(email);
ComponentAccessor.getMailQueue().addItem(item);
Date today = new Date()
return "Success"
} catch (MailException e) {
log.error e.message
}
} else {
log.warn "Sending is disabled"
}

 

Or, as you suggested, use the custom listener to fire a new event using the isseEventManager

import com.atlassian.jira.component.ComponentAccessor
def issueEventManager = ComponentAccessor.issueEventManager
issueEventManager.dispatchEvent(eventId,issue, user,false)

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events