...
Info | ||
---|---|---|
| ||
Power Actions Actions™ for Jira Level: BASIC |
Use case
Sometimes project manager or any other Jira user who can view the issue, wants to send a personalized e-mail to certain email address. This message will not to be sent automatically, unless the user explicitly knows to whom he wants to send it.
This example shows how to do that by using Power Actions Actions™ for Jira and the SIL Simple Issue Language™.
Solution
Power Actions Actions™ Custom Field that creates an email and sends it to the recipients enables you to resolve the use case.
Step 1: Create a new Power Actions Custom Field
- Go to Jira Administration > Issues > Custom Fields.
- Click Add Custom Field to add a new custom field.
- Select Power Actions Power Actions™ Custom Field. Click Next.
- Give a name Email Issue and description to your field. Click Create.
- Check Issue screens you want your field to be reflected in.
- Click Finish.
Step 2: Configure your custom field
- To configure created custom field go to cog wheel menu. Click Configure.
- To create a button that triggers the dialog for the email details click Edit Buttons.
- To Add New Power ActionAction™ insert a Button Text for instance Send Email. Click Add.
- 5 links for this button in the right of the screen will appear. The first three of them are the SIL SIL™ scripts that controls it.
- The 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 Screen Script enables you to determine if the send email action requires additional data and builds a form that the user can fill in.
- The Action Script sends the email you want to the specified email addresses.
Step 3: Configure the Screen Script
Click the Edit Screen Script link. Write the following SIL SIL™ script code in the panel. This code will create two input boxes for the email addresses (to and cc), another input box for the subject, an unlimited text area for Email body and a File Upload field for attachments.
Code Block language actionscript3 title Screen Script Code boolean isDisabled = false; string [] ret = BA_createInput("Send to", "admin@kepler-rominfo.com", isDisabled); ret = arraysConcat(ret, BA_createInput("CC", "", isDisabled)); ret = arraysConcat(ret, BA_createInput("Subject", "Your issue email title", isDisabled)); ret = arraysConcat(ret, BA_createTextArea("Email body", "Write your email here", isDisabled)); ret = arraysConcat(ret, BA_createFileUpload("Attachments", isDisabled)); return ret;
- Save the code and go back to the Configuration page.
Step 4: Configure the Action Script
Click the Edit Script link. Write this SIL SIL™ code in new page.
Code Block title Action Script string[] to = replace(BA_getSingleValue(argv, "Send to"), ",", "|"); string[] cc = replace(BA_getSingleValue(argv, "CC"), ",", "|"); string subject = BA_getSingleValue(argv, "Subject"); string body = BA_getSingleValue(argv, "Email body"); string[] attachments = BA_getMultiValues(argv, "Attachments"); return sendEmail(userEmailAddress(currentUser()), to, cc, subject, body,"en_US", attachments);
This code provides the following actions:
- Takes the email addresses that the user filled in and if there are more than one email creates a list with all of them.
- Gets the subject of the email.
- Builds the body of the message by using a template or by creating the email body from the text that the user filled in.
- Gets the paths from the attachments from the Attachments field of the Email Issue custom field.
- Sends the email with all the details filled by the user that send the email.
Note, you can use a template for the email which means that you have to create a template file that contains all the relevant fields of the issue. Also, for more information about sending an email using SIL see the sendEmail routine.
Step 5: Build the email template
To create the email template go to Jira Administration > System > cPrime Plugin Configuration > Mail Sender Configuration.
...
Info | ||
---|---|---|
| ||
You can see the Email Templates page for detailed information. Also see the Mail Configuration section. |
Example
You can now test this custom field by checking the issues you have selected in the first step of this recipe.
...
Info | ||
---|---|---|
| ||
In order to use this recipe with katl-commons SIL Engine™ version 2.5.0, 2.5.1, 2.0.10 due to some problems you will need to make the following settings:
Katl-commons SIL Engine version 2.5.2 and higher does not need this configuration. |
See also
Email Issue from Power Actions Actions™ for Jira