Transitioning Issues Based on Custom Field Conditions
Overview: This KB article guides how to configure a Jira workflow to transition issues automatically based on conditions evaluated from custom fields.
Instructions:
Identify Custom Fields: First, identify the custom fields you want to use for your conditions. In the provided example,
customfield_11778
andcustomfield_13163
are single-select custom fields. Ensure these fields are correctly configured in your Jira instance.Determine Transition IDs: Determine the transition IDs for the transitions you want to trigger based on the conditions. In the provided example, transition names
Done
andEscalate
are used. You can find these IDs by inspecting your workflow configuration in Jira administration.Create a 'Transition issue(s) ' Post-Function: Navigate to your workflow configuration and add a 'Transition issue(s)' post-function to the transition leading to the 'DONE' status. Choose 'Calculated Transition' and insert the following code:
{% if issue.customfield_11778 == null or (not issue.customfield_13163 or not issue.customfield_13163.value) %}
21 (Done@@Software Simplified Workflow for Project ABC) or (Transition ID(s))
{% else %}
41((Escalate@@Software Simplified Workflow for Project ABC)or (Transition ID(s))
{% endif %}
Note : It’s always recommended to use Transition ID(s) instead of name(s) in the script.
Here's the breakdown of the script and its use-case:
Use-case: The script aims to determine the transition to be executed on an issue within the "Software Simplified Workflow" for a project named "Project ABC."
Conditions:
If
customfield_11778
is empty (null
) or ifcustomfield_13163
is empty or does not have a value (not issue.customfield_13163 or not issue.customfield_13163.value
), then the "Done" transition is selected for execution.If the above conditions are not met (i.e.,
customfield_11778
is not empty andcustomfield_13163
has a value), then the "Escalate" transition is chosen for execution.
Transition Execution:
If the conditions for the "Done" transition are met, the script returns
Done@@Software Simplified Workflow for Project ABC
21(Transition ID(s)).If the conditions for the "Escalate" transition are met, the script returns
Escalate@@Software Simplified Workflow for Project ABC
41(Transition ID(s)).
Replace customfield_11778
and customfield_13163
with the correct IDs of your custom fields. Also, replace the Name of the workflow with the name of your workflow.