Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

Sending email through Script runner when custom field value updated

Edited
Jane I'm New Here Jan 06, 2022

Hi All, 

As a project manager, I want stakeholders to be informed by sending email when the endDate which is custom field is behind schedule.

I've tried multiple examples of code that sends an email from a listener and they all fail at filter the above requirement.

scriptRunner_01.png

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.properties.APKeys
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

def
jiraBaseUrl = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)
def link="${jiraBaseUrl}/browse/${issue.key}"

def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "endDate"}
if (change) {
    log.debug "Old value(OriginalEndDate) : ${change.oldstring}"
    log.debug "New value(UpdatedEndDate) : ${change.newstring}"   
log.debug "Value changed by ${event.user} at ${event?.getChangeLog()?.created}"

// I want to send email above logs to stakeholders when New value(UpdatedEndDate) - Old value(OriginalEndDate) >= 1
}

When I've tried to create Send a custom email(non-issue events) for using CustomFieldUpdatedEvent, Every line seems to be needed as the validator complains. 

How can I send email Associating proper script with the event listener?

Thank you in advance for your help.

1 answer

0 votes
florianper Community Leader Jan 07, 2022

Hello,  

I think the subscribe filter feature can do this :

https://www.atlassian.com/blog/jira-software/jql-the-most-flexible-way-to-search-jira-3-of-4 

If not let me know and I'll help you to find a way to achieve want you want to do !  

Suggest an answer

Log in or Sign up to answer
TAGS

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