How to send a customer e-mail to a specific group when a custom field is updated

Rimet Hynniewta January 24, 2021

I want to notify a group when a project manager field ( Custom field) is updated with the name of the project manager.

I have Script runner and I tried to create a listener using the Issue Event update. What I think I need to do is to create a condition. Maybe the condition should be if the project manager field is not null.

I am not a developer so I do not know what the script should be

Please let me know

Rimet

3 answers

0 votes
Brian Swackhamer July 14, 2022

1. Create a listener in script runner for updates - which you did

2. Add code to look at the right field to check the values

My example as I had a multi-select but can be modified for a single select

///////This is to get the Product(s) list

    def cField = customFieldManager.getCustomFieldObjectsByName("Product(s)"

    def cFieldValue = issue.getCustomFieldValue(cField[0]) as List

    

  //Need to loop through the products as based on that information we may need to send to various folks

 cFieldValue.eachWithIndex { it, i ->

    BodyText = BodyText + "<br> &emsp;&emsp;&emsp;&emsp;&emsp;" + it.value //creates a running list of values

    projectRole1 = ComponentAccessor.getComponent(ProjectRoleService).getProjectRoleByName(it.value, new SimpleErrorCollection()) //get project roles as that was my grouping

    actors1 = ComponentAccessor.getComponent(ProjectRoleService).getProjectRoleActors(projectRole1, issue.projectObject, new SimpleErrorCollection()) //getting the 

   

//checking to make sure I have folks in my group and if so I am building an address list

    if (actors1 != null){

        ReceiptiantAddress = ReceiptiantAddress + actors1?.getApplicationUsers()*.emailAddress.join(",")

    }

}
0 votes
Rimet Hynniewta June 17, 2021

Solution - For anyone, I managed to do this by creating a post function, so when a ticket  moves to any transition, it will send an e-mail based on the user in the custom field - Project manager. This will only work if the custom field is a single user picker list so please bear that in mind.

0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 24, 2021

Hi Rimet - Welcome to the Atlassian Community!

You can easily do that with Automation For Jira which is free in Jira Cloud.

Here's some information to get you started:

There are two types of automation:

  • Global: In the Free version, you get 100 executions per product, per month
  • Project: In all versions, you get unlimited executions per month

Automation Basics: https://www.atlassian.com/software/jira/guides/expand-jira/automation

You can do this via global rules to apply to all projects also. You'll need to be a Jira Admin/Site Admin, go to Jira Settings > System > Automation Rules (left-hand menu).

For more on using Automation For Jira see these help pages.

Jira Automation Template Library to help get you started quickly:

https://www.atlassian.com/software/jira/automation-template-library#/labels/all/customLabelId/1453

Basically, you want to create a new Rule with a Trigger for Field Value Changed and select the Project Manager field.

Then add a Condition to check if the value = the name of the certain project manager.

And then add a New Action for Send email. In the To: section, put in the group. 

Rimet Hynniewta January 26, 2021

I am using Jira Server and have Sriptrunner installed and created a Listener based on Issue Updated event. 

But I need to make sure that the condition is applied if the customer field ( User Picker list) is not null.

The idea was to send the email when the project manager updated this field

As I do not have the skill to write the code, I am struggling to define the condition and tried this code.

cfValues['customFieldId_35149']?.value but it gives an error

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 27, 2021

That's why I use Automation for Jira - I do not have to write code. And it comes Free with Jira Cloud. Sorry, but I don't have experience with ScriptRunner or writing code as such. 

Rimet Hynniewta January 27, 2021

Can you get Automation for JIRA for server version

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 27, 2021

Sorry, I see now that you are using Server. There is a Lite version that is free and also a paid version. Here is a link that shows the different capabilities between the two.

https://confluence.atlassian.com/automation/getting-the-right-version-993924597.html

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events