Performing additional processing after a transition is executed

JIRA allows you to perform additional tasks as part of a workflow transition through the use of post functions. JIRA makes heavy use of post functions internally, for example, in the case of an out-of-the-box workflow, the resolution field value is cleared automatically when you reopen an issue.

In this recipe, we will look at how to add post functions to a workflow transition. We will add a post function to automatically clear out the value stored in the Reason for Freezing custom field when we take it out of the Frozen status.

Getting ready

By default, JIRA comes with a post function that can change the values for standard issue fields, but since Reason for Freezing is a custom field, we need to have the JIRA Suite Utilities add-on installed.

You can download it from the following link, or install it directly using the Universal Plugin Manager:

https://marketplace.atlassian.com/plugins/com.googlecode.jira-suite-utilities

How to do it...

Perform the following steps to add processing logic after a workflow transition is executed:

  1. Select and edit the workflow to configure.
  2. Select the Diagram mode.
  3. Click on the Frozen global workflow transition.
  4. Click on the Post functions link on the right-hand side.
  5. Click on Add post function, select Clear Field Value post function from the list, and click on Add.
  6. Select the Reason for Freezing field from Field, and click on the Add button.
  7. Click on Publish Draft to apply the change.

With the post function in place, after you have executed the transition, the Reason for Freezing field will be cleared out. You can also see from the issue's change history, as part of the transition execution, that where the Status field is changed from Frozen to Open, the change for the Reason for Freezing field is also recorded.

How it works...

Post functions are run after the transition has been executed. When you add a new post function, you might notice that the transition already has a number of post functions pre-added; this is shown in the screenshot that follows.

These post functions are system post functions that carry out important internal functions, such as keeping the search index up to date. The order of these post functions is important.

Tip

Always add your own post functions at the top of the list.

For example, any changes to issue field values, such as the one we just added, should always happen before the Reindex post function, so by the time the transition is completed, all the field indexes are up to date, and ready to be searched.

How it works...
..................Content has been hidden....................

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