How To: Send an email to a role using the Send Email step

This topic illustrates how you can use the Send Email step to send a email to members in a K2 Role.

Use the Send Email step to send an email to a role

Scenario

When a leave request is approved or rejected, email notifications need to be sent to certain roles within your organization.

For this scenario we use sample users. You can create your own test users to work with. Depending on the type of scenario you build, you may need to configure specific security settings such as Designer authorization for these users. For more information about managing your environment see the Administer section.

Steps

For this scenario, you configure roles in K2 Management and build a simple leave request workflow with a Send Email step to send an email to members within the role when a leave request is approved or rejected. You create a view from a SmartObject, then add it to a form. The workflow consists of a simple Task step and two Send Email steps linked to the configured Decision outcomes.

Setup Steps

The following steps set up the scenario from start to finish. If you want to skip the setup steps and view the topic step, go to Add Send Email steps and configure the To sections with the UMUser Email SmartObject property.

  1. Create a SmartBox SmartObject called Leave Request. Add properties using the table below as a guide. (Optional: Add categories first to K2 Designer to keep your work organized.)
    PropertyType
    IDAutonumber
    Leave Request TitleText
    Employee NameText
    Employee EmailText
    Leave Start DateDate
    Leave End DateDate
    Leave TypeText
    Requester CommentsMemo
    Requester StatusText
    Approver CommentsMemo
    1. Launch K2 Designer.
      If you do not know how to access K2 Designer, see Accessing K2 Sites.
    2. Create a new category called Leave Request.
    3. Create a SmartObject called Leave Request. Click Finish
      .
  2. Generate a View and Form
    1. Click Generate a View on the Leave Request SmartObject screen.
    2. On the Generate Options screen, select the Item and Generate Form options. Click OK.
  3. Edit and configure the Leave Request Item View
    1. Edit and configure the Leave Request Item View as shown below:
    2. Add a Button control to the item view and rename it to Submit.
    3. Select the Submit button control and click Add Rule in the Rules tab.
    4. On the Rule Designer screen, select the Actions tab and select the Execute a SmartObject method action.
    5. Click the Select Method option and select the Create method.
    6. Click Configure. Click Auto Map and then Finish.
    7. Click OK then Finish.
    8. Check in the Leave Request Item View.
  4. Edit and Configure the Leave Request Form
    1. Edit the Leave Request form.
    2. Select the Views tab and add the Leave Request Item View to the form.
    3. Click Finish and check in the form.
  5. Configure the Leave Request Workflow
    1. Select the Leave Request Form and click Design Workflow.
    2. Name the workflow Leave Request Workflow.
    3. Select the Start step and click Add a SmartForm start event.
    4. On the Choose SmartForm screen , select the Leave Request Form and click OK.
    5. Click Next on the Start Workflow from a Form screen.
    6. Select the Help me configure it option and click Nexton the Start Workflow from a Form screen. Click Next again
    7. Select the On Leave Request Item View, when Submit is Click option from the Form Rules section and click Next.
    8. Click Save and Finish.
    9. Click OK.
  6. Add and Configure a Task and Decision Steps
    1. Add a Task step from the Toolbox to the canvas.
    2. In the Actions section select Both. Rename the Task step to HR Approval.
    3. Add a Decision step to the canvas and connect it to the HR Approval Task step.

Add Send Emails steps and configure the "To" section with roles

The step below explains how to configure the Send Email steps with roles.

  1. Add Send Email steps and add the UM User Email property to the To section.
    1. Add a Send Email step to the Approved decision. Rename the Send Email step to Approved. Configure the Subject and Body sections.
    2. On the To section, select the Type/Construct my own option.
    3. Expand the Context Browser section and select the SmartObjects tab.
    4. Search for the UMUser SmartObject and select it.
    5. Select the Get Role Users option.

    6. Select the Email option and drag it to the To section. Select the All items as a collection option. This configures the email to be sent to all users in the role.
    7. Type the name of the role you want the email to be sent to in the Role Name section. In this scenario we send the email to the Finance Management Role.
      Ensure you create your roles prior to configuring the Send Email steps. See the Roles section in K2 Management for more information.
    8. Add another To option and select the Originator option. This ensures the user who submitted the Leave Request also gets sent the Approved or Rejected email.
    9. Repeat the above mentioned steps for the Rejected decision.
    10. Deploy the Leave Request Workflow.
  2. Test the Scenario

    In the following scenario Codi submits a leave request which is sent to the HR department for approval. Once approved or rejected, Codi and the her managers in the Finance department will receive an approved or rejected email. The Finance managers are part of a role called Finance Management Role. The emails from the approved or rejected request are sent to all members of the Finance Management Role and Codi.

    1. Codi completes the Leave Request form and clicks Submit.
    2. The leave request is approved by the HR department.
    3. Codi receives the approval email.
    4. Members of the Finance Management Role (Holly and Dennis) also receive the approval email.

Review

In this how to you created a leave request application with a SmartObject, View, Form, and a Workflow. When the Leave Request form was submitted and approved or rejected, the emails for the approved or rejected request were sent to the originator and to members of a role.