Example Workflow Extension

Atlassian's new transition experience in Jira is being permanently rolled out in April 2025. As a consequence, how your Jira expressions (conditions and validators) work will change. Check out our Breaking Changes section for more information.

ScriptRunner for JIRA Cloud provides several built-in post functions to help you get started with Workflows, and you can refer to our example custom scripts. You can also use one of the many Jira expression examples, which can be applied to either conditions or validators and on all transitions unless noted otherwise. 

Example: add a post function workflow extension 

By way of an example, if you would like to add a Post Function to an existing Jira workflow, follow the steps below:

  1. Navigate to the Workflows menu from within Jira's settings. You will see Active and Inactive workflows displayed.
  2. Click Edit from the Actions ellipsis for your chosen workflow, and the workflow opens. You can choose to view the workflow as a diagram, or text, we will use the former for this example.
  3. Select a transition from within the workflow diagram. A list of associated workflow functions, including Conditions, Validators, Post Functions, Triggers, and Properties, is displayed for the selected transition.
  4. Click Post Functions, and the workflow's transition options appear.

  5. Click Add post function.
  6. Select the ScriptRunner Post Function option and click Add. The Add Parameters to Function screen appears:
  7. Select a post function from the list of available functions. For example, choose Add/remove from sprint. You will now see the Configuration screen.
  8. In the Description field, enter a short description of the post function.
  9. Select Enable Post Function to enable it as soon as it is added.
  10. Select an Example script from the provided list of examples. These can help you get started writing your script in the console. 
  11. Choose from the Action drop down whether to add to a sprint or remove from a sprint.
  12. Choose from the Board Name drop down whether to assign the post function to a particular board.
  13. Choose whether to run the script as an Initiating User or ScriptRunner Add-On User in the Run As dropdown.
  14. Click Add, and you are returned to the workflow transition, where you will see the newly added post function appear.

You can edit the script for the post function from the workflow itself or quickly access it at any time via the Workflows tab within ScriptRunner for Jira Cloud.

Remember, you can only view Workflows in ScriptRunner for Jira Cloud if you have already created a condition, validator or post function from the Workflows within the Jira Administration menus. Once added within Jira, the workflow then appears in the Workflows section of ScriptRunner for Jira Cloud, where you can edit or disable it.
  1. Navigate to ScriptRunner > Workflows. 
    All existing workflows are displayed. You can refine your search by selecting the type of transition option from the Type drop down list (Condition, Validator, or Post Function), or the Workflow Status (active or inactive). You will now see a refined list displayed.
  2. Click the Actions ellipsis for your preferred workflow and select either Edit or Disable.
  • If you choose to disable the chosen workflow, you can confirm this via a confirmation message once prompted.
  • If you choose to edit the chosen workflow, you will see the workflow details screen displayed from where you can make the required edits to an existing workflow. For example:
    1. Write your script in the code editor. This code is executed when the Condition is true.
      OR
      Alternatively, click Example scripts to view a list of example scripts related to this feature.

      So, rather than writing your own script, you can reuse one of the many examples provided, as follows:

      - Choose an example script from the list provided, and the code automatically appears. You can also search for a particular script.
      - Click Copy Code and then Close.
      -
      Paste the copied code in the code editor.
    2. Click Save.


On this page