How to fire an event using Script Runner when custom multi user field gets updated?

Hi,

I want to fire an event using Script Runner when a custom multi user field is changed. The users in this field should get a notification after the change of the field. What is the correct condition to fire the event? In the best case only newly added users to the custom field will be notified.

Thanks in advance
Thorsten

2 answers

1 accepted

Hi Thorsten,

In such a case you could use event.eventTypeId:

import com.atlassian.jira.event.type.EventType
if (event.eventTypeId == EventType.ISSUE_CREATED_ID) {
    true
} else if (event.eventTypeId == EventType.ISSUE_UPDATED_ID) {
    changeItems.any { it.field=='my multi user field' }
}

Hope that helps

Hi Alejo,

 

it works.

Thank you very much.

 

Best Regards
Thorsten

Hi Thorsten,

For that purpose you can create a Script Listener of type "Send a custom email".

In the configuration of that listener you will need to add a condition similar to the following one:

changeItems.any {
    it.field=='my multi user field'
}

And also add your custom field id to the "

Hi Alejo,

 

thank you very much. It works.

But in the case I create the issue it doesn't work. I selected both events issue created and issue updated. But I think that the condition is not true because only the update case is covered. Can I change the condition so that also the create case is covered?

 

Best Regards
Thorsten

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

243 views 1 18
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you