Fires an Event when Condition is True

The Fires an event when condition is true post function enables you to trigger a specific Jira event based on a custom condition. Once fired, the event can be picked up by a notification scheme, determining who gets alerted.  

Jira events, such as the Issue created or Issue updated event, are predefined occurrences in an issue's lifecycle. This post function allows you to fire these events even if that event wouldn't normally be triggered at that point in the workflow. This post function only fires the event when your specified condition is met, providing precise control over when notifications are sent.

By combining custom conditions with Jira's existing event types and notification infrastructure, you can create highly targeted alerts. This post function bridges the gap between Jira's standard event system and your workflow's unique requirements, allowing for more flexible and responsive issue management and communication.

To make the most of this post function we recommend you familiarise yourself with Jira events and notification schemes

Example

As an example, we have a software development project in Jira, and we want to automatically notify the QA team when a high-priority bug is resolved. We would do the following:

  1. Create a custom event in Jira called High Priority Bug Resolved.
  2. Create a notification scheme in Jira that listens for this custom event and sends an email to the QA team.
  3. Locate the transition where we want to add this post function (for example from In Progress to Resolved).
  4. Add this post function to the chosen transition.
  5. Use the following condition in the post function:
    groovy
    issue.priority.name == "High" && issue.issueType.name == "Bug"
  6. Specify the event to be fired when the condition is true. In this case, we would use the custom event High Priority Bug Resolved.

The above is a summary of the steps you would take to create a Jira event, a notification scheme, and this post function. See below for more detailed steps on how to set up this post function. 

Use this post function

  1. Go to Administration > Issues > Workflows.
  2. Select Edit on the workflow you want to add this post function to. 
  3. Select the transition you want to add this post function to.
  4. Under Options, select Post Functions.

  5. On the Transition page, select Add post function.
  6. Select Fires an event when condition is true.

  7. Select Add.
  8. Optional: Enter a note that describes the post function (this note is for your reference when viewing all post functions).
  9. Enter a condition. If no condition is specified, then this post function will always run.
  10. Choose the event you want to fire when the condition is true
  11. Select Preview to see an overview of the change. 
  12. Select Add.

  13. If applicable, reorder your new post functions using the arrow icons on the right of the function (they can only move one line at a time). Check out our documentation on Post function order for more information.

  14. Select Publish and choose if you want to save a backup copy of the workflow.

    You can now test to see if this post function works.



Related content

On this page