Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


Send an email when user custom field is updated - to the corresponding user's email

Hi there Atlassian Community,

I have a user custom field called 'Champion/ Owner'. I want to set up a ScriptRunner listener that will send an automated email to the user listed in the 'Champion/ Owner' field when that field is updated.

  1. 'Champion/ Owner' field currently has a Jira user populated
  2. 'Champion/ Owner' field is updated with a different Jira user
  3. Email gets sent to the new 'Champion/ Owner' user's corresponding email

I've found and put together the following in the Condition area:

import com.atlassian.jira.event.issue.field.CustomFieldUpdatedEvent

def change = CustomFieldUpdatedEvent.find { it['field']=='Champion' }
def newValue = change['newvalue']
def oldValue = change['oldvalue']

this isn't throwing any errors, but I don't know how to add the send email 'To' part of it.

I found some older posts that say to just put the "customfield_num" in the 'To' piece of the email listener or versions of that and everything I add in there throws an error  "These don't look like valid email addresses:"

How do I set up the rest of either the condition, or what do I put in the 'To' line to have the email sent to the the corresponding user email?

1 answer

0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 23, 2021 • edited

Maybe it's because of a different version of Jira (i'm on 8.13), but I don't have access to that specific event.

But without trying it, my initial assumption is that this event is about the Custom Field configuration itself being changed, not an issue's custom field value changing. 
Looking at the 8.20 documentation for that event, I think my assumption bears out 

I think what you really want, is to use the "IssueUpdatedEvent" and then look at the list of fields in the ChangeLog.

* Condition to test if a field was modifid
import com.atlassian.jira.component.ComponentAccessor
def fieldName = 'Champion/ Owner'
def changeLog = event.changeLog
def changeItems = changeHistoryManager.getChangeHistoryById( as Long).changeItemBeans
return changeItems.any{it.field == fieldName)
return false

As for actually sending the email, I'm assuming you're using this scriptrunner built-in listener ?

If so, you should be able to just specify the Champion/Owner in the "To Issue fields" part of the configuration. If you can't find your field in that lookup, then your field is not of the right type.

If you enter "user" information, that field should be a "User Picker" custom field.

If that's not the case, You'll need to write some code to find the correct user from that field and extract the user's email.

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events