Creating custom events

In the previous recipe, Sending notifications for issue updates, we looked at how to set up notification schemes by mapping events to notification recipients.

In this recipe, we will expand on that and look at how to create our custom events. This has two obvious advantages:

  • We can map our own e-mail templates to these custom events
  • We can specify exactly what event will be fired for each workflow transition and set up notification rules accordingly

How to do it…

Proceed with the following steps to create custom events in JIRA:

  1. Navigate to Administration | System | Events.
  2. Enter the new event's name.
  3. Select a template that will be used for the e-mail notification when the event is fired. You can select from a list of JIRA-bundled templates or the custom templates you created.
  4. Click on the Add button to create the new event, as shown in the following screenshot:
    How to do it…

Once you have created the events, they will be available in notification schemes, and we will be able to select who will receive e-mail notifications, as shown in the following screenshot:

How to do it…

The last step is to make sure our custom events are fired when users trigger the action:

  1. Navigate to Administration | Issues | Workflows.
  2. Click on the Edit link for the workflow, which contains the transitions that will fire the custom event. In this case, we will be using a simple Approval Workflow that contains a transition called Approve:
    How to do it…
  3. Click on the workflow transition and select the Post Functions tab. Normally, you will see the last post function in the list firing Generic Event.
  4. Hover your mouse over the post function and click on the edit icon (it looks like a pencil).
  5. Select the new custom event and click on Update as shown in the following screenshot. This will make the transition to fire our event instead of the default Generic Event.
    How to do it…

How it works…

Unlike system events, custom events can only be fired from workflow transitions, so we have to update our workflows. Every workflow transition fires an event, and by default, Generic Event is fired. This means most workflow transitions will have the same notification recipient using the e-mail template.

By configuring the workflow to fire our own custom event, we have finer control over who will receive notifications and what templates to use, as we will see in the next recipe, Creating custom e-mail templates.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset