On this page
Use case
Create a hierarchy of issues by prioritizing them via a Number Field and a couple of post functions in the Create transition and a global reflexive transition that will update the hierarchy after a new value has been modified or introduced.
Prerequisites
Create a new global reflexive transition (from any issues to itself) and add it a custom screen that includes the Customer Prioritization field.
Configuration
Target issue*
Select Set target issues manually (parser expression) and add the following expression:
issuesFromJQL("issuekey != " + %{00015} + " and \"Customer Prioritization\" >= " + {issue.cfCusPrio} + " order by \"Customer Prioritization\" ASC")
This expression will select all of the existing issues whose Customer Prioritization field value is greater than or equal to the existing one excluding the one from the current issue.
Field*
Select the Customer Prioritization field and add the following expression.
{nnnnn} + indexOf(^%{00015}, issuesFromJQL("issuekey != " + %{00015} + " and \"Customer Prioritization\" >= " + {issue.cfCusPrio} + " order by \"Customer Prioritization\" ASC"))
Conditional execution
%{nnnnn} != null
Target issue*
Select Set target issues manually (parser expression) and add the following expression:
(previousValue({issue.cfCusPrio}) = null ? issuesFromJQL("issuekey != " + %{00015} + " and \"Customer Prioritization\" >= " + {nnnnn} + " order by \"Customer Prioritization\" ASC") : ({issue.cfCusPrio} < previousValue({issue.cfCusPrio}) ? issuesFromJQL("issuekey != " + %{00015} + " and \"Customer Prioritization\" >= " + {issue.cfCusPrio} + " and \"Customer Prioritization\" <= " + previousValue({issue.cfCusPrio}) + " order by \"Customer Prioritization\" ASC") : issuesFromJQL("issuekey != " + %{00015} + " and \"Customer Prioritization\" >= " + previousValue({issue.cfCusPrio}) + " and \"Customer Prioritization\" <= " + {issue.cfCusPrio} + " order by \"Customer Prioritization\" DESC")))
This expression will cover three possible situations:
Case 1 - There was no previous value in the custom field Customer Prioritization: The expression will fetch the issues as in the create transition.
Case 2 - The value entered in the custom field Customer Prioritization is smaller than the previous value: The expression will fetch all issues whose Customer Prioritization value is greater than or equal to the entered value and smaller than or equal to the previous value in an ascending order.
Case 3 - The entered value is greater than the previous value: The expression will fetch all issues whose Customer Prioritization value is greater than or equal to the previous value and less than or equal to the entered value in a descending order.
Field*
Select the Customer Prioritization field and add the following expression.
(previousValue({issue.cfCusPrio}) = null ? {issue.cfCusPrio} + indexOf(^%{00015}, issuesFromJQL("issuekey != " + %{00015} + " and \"Customer Prioritization\" >= " + {issue.cfCusPrio} + " order by \"Customer Prioritization\"")) : ({issue.cfCusPrio} < previousValue({issue.cfCusPrio}) ? ^{issue.cfCusPrio} + 1 : ^{issue.cfCusPrio} - 1))
Depending on the previous cases, a number will be added or deducted from the Customer Prioritization value of each issue of the issue list.
Related use cases
If you still have questions, feel free to refer to our support team.