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, with the out-of-the-box workflow, when you reopen an issue, the resolution field value is cleared automatically.

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 Backlog custom field when we take it out of the Backlog status.

Getting ready

By default, JIRA comes with a post function that can change the values for standard issue fields, but since Reason for Backlog 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…

We need to create a new custom field configuration scheme in order to set up a new set of select list options:

  1. Select and edit the workflow to configure.
  2. Select the Diagram mode.
  3. Click on the Move to Backlog global workflow transition.
  4. Click on the Post functions link towards 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 Backlog 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 Backlog field will be cleared out. You can also see from the issue's change history as a part of the transition execution that where the Status field is changed from Backlog to Open, the change for the Reason for Backlog 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 have noticed 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. For example, any changes to issue field values, such as the one we just added, should always happen before the Re-index 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…

Tip

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

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

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