Email Issue from Power Actions™ for Jira
Required apps
Level:Â BASIC
Problem
In certain situations some users needs to be informed about new issues or changes in the issue fields by the project manager or other users with specific roles in the project. Also, these emails are not to be automatically sent because not all the changes or issues need an email notification.
Our Power Actions™ for Jira app offers you a very simple solution to build and send emails to all or certain project members at a click of a button.
This solution presents one of many that the Simple Issue Language™ and Power Actions™ for Jira can implement.
You can simply let your imagination run free ...
Solution
In order to solve this issue you will have to use a Power Actions™ custom field that builds an email via a template and sends it to its recipients.
Step 1: Create a new Power Actions™ Custom Field
The first step consists in creating a new Power Actions™ custom filed, as follows:
- Go to Administration page.
- In this page go to the Issue section.
- Here you will find a link named Custom Fields; you should click on it.
- Add a new custom field from the button in the right top of the screen ("Add Custom Field").
- Choose the Power Actions™ Custom Field option and press Next.
- Name this newly created custom field: "Email Issue".
- Choose your applicable issue types and applicable context in order to view the new created custom field only on certain issues and projects - as you desire. By default the custom field is visible in global context.
- Click Finish.
Step 2: Configure your Power Actions™ Custom Field
Configure Email Issue custom field by doing the following:
- Choose the cog icon at right of the screen for your "Email Issue" custom field. This can be done by going to the Custom Fields page.
- Click the Configure link.
- Now we'll need to create a button that will trigger the email sending action.
- Click on the Edit Buttons link. You will find it on the bottom of the page in the section named Buttons.
- Add New Power Actions™ by creating a Button Text called: "Send Email". Press the Add button.
- At the end of this operation you'll see 5 links for this button in the right of the screen.
- The first three of them are the SIL scripts that controls it.
- The first script, named Condition Script, contains the condition for the button visibility. The default value is visible, so if you want all the user to see and action this button you can let the default script.
- The second Script, named Screen Script, allows you to determine if the send email action requires additional data.
- The third Script , named Action Script, sends the email you'll want to the specified email addresses.
Step 3: Configure the Power Actions™ Screen Script
In order to send the email you will need to configure the Power Actions™ Scripts.
As we said previously, the Condition Script can be configure in order to prevent certain users to send the emails. For more information please use the Condition Script page.
The Screen Script is used to show a message on the screen in order to confirm the email sending action. This is a security measure to prevent an accidental click on this button.
To edit this script click the Screen Script link from the Configure Email Issue page. Add the following code:
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 will show a read only message in the screen.
Step 4: Configure the Power Actions™ Script
The Action Script is the one that sends the email to the desired users. To edit the Action Script click the Script link from the Configure Email Issue page and add the following code:
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 about sending an email using SIL™ please read the sendEmail routine page.
Because we used in the previous code a email template we'll need to create and use this template named: template.tpl.
Step 5: Build the email template
After the installation of the plugin, in the "Administration" menu, a new option will appear named "Kepler General Parameters". Go there and select "katl-commons" plugin from the Select plugin list. A configuration option named "Email Template Directory" depicts the directory where the templates are kept. The directory path is relative to the jira.home.dir/kepler. The rest of the email configuration is extracted from the standard JIRA configuration (Administration->Mail Servers->SMTP Mail Server).
You can create a new template in this folder using your desired text editor. You can add certain issue field values in the template by using the $field$ notation, where field is the name of the field you want to put in the text. Here is an example:
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
You can consult the Email Templates page for further information. Also consult the Mail Configuration page.
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 screen will have the Send Email button, like this:
After you click the button you'll need to confirm your email:
Click the Execute button and the email will be sent.
That's all. You just saved 100 US dollars, so for sure you can eat at least a chocolate bar.
Working solution
In order to use this recipe with SIL Engine™ version 2.5.0, 2.5.1, 2.0.10 you will need to make the following settings:
- Download the mail.jar and the activation.jar archives from the maven repository (or any other).
- Create a folder on your system named endorsed and put those two archives in the folder.
- If you are using Windows create a new environment variable named "JAVA_ENDORSED_DIRS" with the value "path_to_endorsed_folder". (Example: set JAVA_ENDORSED_DIRS="D:\JiraInstall\endorsed").
- Or you can specify your endorsed folder as a java system property like so:
-Djava.endorsed.dirs="D:\JiraInstall\endorsed" with your endorsed directory path.
SIL Engine version 2.5.2 and higher does not need this configuration.
See also
Email from Power Actions™ for Jira