Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
titleRequired apps

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

  1. Go to Jira Administration > Issues > Custom Fields.
  2. Click Add Custom Field to add a new custom field.
  3. Select Power Actions Power Actions™ Custom Field. Click Next.
  4. Give a name Email Issue and description to your field. Click Create.
  5. Check Issue screens you want your field to be reflected in. 
  6. Click Finish.

Step 2: Configure your custom field

  1. To configure created custom field go to cog wheel menu. Click Configure.
  2. To create a button that triggers the dialog for the email details click Edit Buttons.
  3. To Add New Power ActionAction™ insert a Button Text for instance Send Email. Click Add.  
  4. 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

  1. 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
    languageactionscript3
    titleScreen 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;
  2. Save the code and go back to the Configuration page.

Step 4: Configure the Action Script

  1. Click the Edit Script link. Write this

    SIL

    SIL™ code in new page.

    Code Block
    titleAction 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);
  2. 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, we you can use a template for the email which means that we 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

After the installation of the plugin, in the "Administration" menu, a new option will appear named "Kepler General Parameters". Go to it and select "katl-commons" app from the Select plugin list. A configuration option named "Email Template Directory" To create the email template go to Jira Administration > System > cPrime Plugin Configuration > Mail Sender Configuration.

A configuration Email Template Directory depicts the directory where  the templates are kept. The directory path is relative to the jira.home.dir/kepler. The  The rest of the email configuration is extracted from the standard JIRA configuration (Administration->Mail Servers->SMTP Mail Server)Jira configuration.

You can create a new template in this folder using your desired text editor. You can add the 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:

...

Info
titleEmail Templates

You can consult see the Email Templates page for further detailed information. Also consult see the Mail Configuration page section.

Example

You can now test this custom field by going to checking the issues you have selected in the first step of this recipe.

The Issue screen will have now has the Send Email button, like this:

The Screen of the Button will appear like this:button screen is as follows

An example of a filled in form:

Click Execute and that's all.

You just saved 100 US dollars, so for sure you can eat at least a chocolate bar.


Info
titleWorking solution

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:

  • Download the mail.jar and the activation.jar archives from the maven repository.
  • 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.

Katl-commons SIL Engine version 2.5.2 and higher does not need this configuration.

See also

Email Issue from Power Actions™ for Jira