- Created by Jonathan Muse, last modified by Cristina Szilágyi on Mar 21, 2023
- Mentions
- 0 Associations
You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 17 Next »
Problem
As a project manager or another user with a specific role in the project, you must notify other users by email about new issues or changes in the issue fields. In addition, these emails shouldn’t be automatically sent because not all new issues or changes require an email notification.
You can use Power Actions™ to create and send emails to all or certain project members.
Solution
To solve this problem, use a Power Actions™ custom field that creates an email based on a template, and sends it to the selected recipients.
Step 1: Create a new Power Actions™ Custom Field
First, create a new Power Actions™ custom field following the instructions below:
Go to the Administration page.
In the Issue section, click Custom Fields.
Click the Add Custom Field button in the upper-right corner to add a new custom field.
Select the Power Actions™ Custom Field option. Click Next.
Rename the new custom field to Email Issue.
Select your applicable issue types and context to view the new custom field only on certain issues and projects. By default, the custom field is visible in global context.
Click Finish.
Step 2: Configure your Power Actions™ Custom Field
To configure the Email Issue custom field, select the cog icon on the right.
Go to the Custom Fields page to find your Email Issue custom field.
Click Configure.
To create a button that triggers the email sending action, go to the Buttons section at the bottom of the page. Click the Edit Buttons link.
Click Add New Power Actions™ and enter Send Email as button text. Click Add.
Five links for this button are now displayed on the right of the page. The first three are the SIL™ scripts that control it. They are:
The Condition Script script. It contains the condition for the button visibility. The default value is visible (the user can see and click this button).
The Screen Script script. It allows you to determine if the email sending action requires additional data.
The Action Script script. It sends the email you want to the specified email addresses.
Step 3: Configure the Power Actions™ Screen Script
To send the email, you need to configure the Power Actions™ Scripts.
The Condition Script can be configured to prevent certain users to send the emails. For more information, go to the Condition Script page.
The Screen Script is used to display a message to confirm the email sending action. This is a security measure to prevent an accidental click of this button.
To edit the script, click Screen Script on the Configure Email Issue page. Add the following code:
Screen Script
string[] ret; ret = BA_createInput("Message", "You are about to send a email message to all members of this project.", true); return ret;
This code displays a read-only message.
Step 4: Configure the Power Actions™ Script
The Action Script sends the email to the specific users. To edit the Action Script, click Script on the Configure Email Issue page. Add the following code:
Action Script
string[] to = projectMembers(project); string[] cc; string subject = "JIRA Email Issue: " + summary; string template = "template.tpl"; string language = "en_US"; print(attachments); if (sendEmail(userEmailAddress(currentUser()), to, cc, subject, template, language, attachments)) { return "The email has been sent succesfuly"; } else { return "An error occured when sending the email."; }
This code sends a template email to all the project members including the current user. For more information on sending an email using SIL™, go to the sendEmail page.
Because an email template was used in the previous code, create and use this template renamed to template.tpl.
Step 5: Build the email template
After the plugin installation, a new Kepler General Parameters option is displayed.
Go to the option and select the katl-commons plugin from the Select plugin list.
A configuration Email Template Directory indicates the folder where the templates are stored. The directory path is relative to jira.home.dir/kepler. The rest of the email configuration is extracted from the standard JIRA configuration (you can find this at Administration > Mail Servers > SMTP Mail Server).
You can create a new template in this folder using your preferred text editor. You can add certain issue field values to the template by using the $field$ notation, where field is the field name you want to enter into the text. Here is an example:
Email Template
Hello $recipient$, This is a test template sent from $assignee$'s issue $key$. The summary for this issue is: $summary$. This issue has the following fields: Type : $type$ Priority : $priority$ Labels : $labels$ Status : $status$ Resolution : $resolution$ $key$ is described as follows: $description$ This issue was created on $created$ and updated on $updated$. It's due date is: $dueDate$. The assignee is $assignee$ and the reporter is: $reporter$. Best regards, $reporter$ This email was automaticaly generated by the JIRA Blitz-Action plugin: https://marketplace.atlassian.com/plugins/com.keplerrominfo.jira.plugins.blitz-actions or http://jira-plugins.kepler-rominfo.com. Please do not reply.
Email Templates
For more information, go to the Email Templates and the Mail Configuration pages.
Test
You can now test this custom field by going to the issues you have selected in the first step of this recipe.
The issue view displays the Send Email button:
Click the button and confirm your email:
Click Execute to send the email.
Table of Contents
- No labels