Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info
titleAvailability

This feature is available for the Jira server deployment option only. We plan to add it to the Cloud version in the near future.

Conditions control who can perform a transition and the circumstances under which they can perform this transition. If any part of a transition's condition fails, the user will not see the transition link on the 'view issue' page.

You can use JJupin and SIL Power Scripts™ for Jira and SIL™ to define a large set of conditions beside Jira's built-in conditions, by just adding a (k) SIL SIL™ Condition to the transition and publishing the workflow, as described here.

Below are just a few The following common examples explain this feature:

Table of Contents

You will need the following JIRA plugin:

  1. JJUPIN
Info
titleRequired plugins
apps

Power Scripts™ for Jira (server)

Level: BASIC

Previous status

A workflow condition that allows enables you to disable a particular transition if the current issue has never been in a specific status:

...

Code Block
titleSIL Code
number STATUS_OPEN = 1;
string[] status_history = fieldHistory(key, "status");
string previous_status = getElement(status_history, size(status_history)-3);

return previous_status == STATUS_OPEN;

Cascading select comparer

A workflow condition that allows you to disable a particular transition when two cascading selects are equals:

...

Code Block
titleCascading select comparer
//Condition Cascading select comparer

if(length(customfield_10000) == 0 && length(customfield_10001) == 0) { //both cascading select are empty
   return true;
}
if(customfield_10000 == customfield_10001) {
   return true;
}
return false;

Condition based on regular expression

A workflow condition that allows you to disable a particular transition when a custom field value doesn't match to a regular expression:

...

Code Block
titleCondition based on regular expression
//Condition based on regular expression

return matches(Combo, "accepted(.)(\\\\d+\\\\.?){10}(.)[a-z]+(-)(\\\\d+\\\\.?)"));

Condition based on linked issues

A workflow condition that allows you to disable a particular transition when the current issue has no linked issues:

Code Block
titleCondition on linked issues
//Condition on linked issues

if(isNull(getLinkedIssues(key)) || return size(linkedIssues(key))==0) {
   return false;
}> 0;

Condition on non-linked issue

A workflow condition that allows you to disable a particular transition when the current issue has linked issues.It's the reverse condition of the SIL code above:

Code Block
titleCondition on non-linked issue
//Condition on non-linked issue

if(isNull(getLinkedIssues(key)) || return size(linkedIssues(key)) ==0) {
   return true;
}
return false; 0;

Condition based on mathematical expression

...

More details can be found on Math Routinesroutines section.

Condition based on date-time expression

A SIL condition which checks if due date is before current datethe day after tomorrow:

Code Block
titleSIL Code
return dueDate > (currentDate() + "2d");

More useful date routines can be found in the Date Routines section. 

Compare two parsed texts

A SIL condition which checks if description contains summary:

Code Block
titleSIL Code
return description.contains(description, summary);

Except assignee Condition

...

Code Block
titleExcept reporter condition
//Except reporter condition

return currentUser() == reporter;

Except in project role condition

A SIL condition that allows you to disable a particular transition when the current logged in user is not in a given project role:

Code Block
titleSIL Code
string ROLE = "Administrators";
return isUserInRole(currentUser(),project, ROLE);

Only/Except users in custom field

A SIL condition that allows you to disable a particular transition when the current logged in user is in a multi user picker custom field (eg Team):

Code Block
titleSIL Code
return elementExists(Team, currentUser());

If you want the transition to be available to any user except the ones from the multi user picker cf Team, you have to negate the previous condition:

Code Block
titleSIL Code
return !elementExists(Team, currentUser());

Users in a field are/aren't in a project role

A SIL condition that makes a transition available only if all users in multi user picker custom field Team are in project role Developers:

Code Block
titleSIL Code
string ROLE = "Developers";
for(string user in Team) {
    if(!isUserInRole(user, project, ROLE)) {
       return false;
    }
}

If you want to disable the transition if at least one user from multi user picker cf Team is in role Administrators, use the following:

Code Block
titleSIL Code
string ROLE = "Administrators";
for(string user in Team) {
    if(isUserInRole(user, project, ROLE)) {
       return false;
    }
}

A custom field is/isn't initialized

A SIL condition that allows you to disable a particular transition if a custom field is not initialized:

Code Block
titleSIL Code
return isNotNull(customfield_10000);

If you want to disable the transition if field is initialized you should use:

Code Block
titleSIL Code
return isNull(customfield_10000);

Check user property

A SILcondition which checks if a user property has a certain value:

Code Block
titleSIL Code
string COUNTRY = "Romania";
return getUserProperty(currentUser(), "country") == COUNTRY;

Condition based on boolean expression

...

Where customfield_11300 and customfield_11301 are JIRA Jira custom fields of type numeric.

Condition based on equality of time spans

Define 3 intervals and compare them in a condition.

...

A SIL condition which checks if there are less than 3 days and a half remaining before the estimated time will be exceeded:

Code Block
interval tstRemaining = "3d 4h";

return tstEstimatetstRemaining ==< (tstSpentestimate +- tstRemainingtimeSpent);

In the example above it is used the addition between tstSpent and tstRemainingsubstraction between estimate and timeSpent, but the user can also use the subtraction between tstEstimate and any of the other 2 intervals.addition between two time intervals in SIL.

All sub-tasks must be resolved

The transition won't be shown unless all sub-tasks are resolved. You can also specify a particular resolution that the sub-tasks must be in (in our example Fixed):

Code Block
string[] subtasks = subtasks(key);
for(string subtask in subtasks) {
    if(%subtask%.status != "Resolved" || %subtask%.resolution != "Fixed") {
       return false;
    }
}

See also