...
Code Block |
---|
|
number STATUS_RESOLVED = 5;
string[] status_history = fieldHistory(key, "status");
if(!return elementExists(status_history, STATUS_RESOLVED)) {
return false;
} |
You can also check if the current issue was not in a specific status just before it entered the current status:
Code Block |
---|
|
number STATUS_OPEN = 1;
string[] status_history = fieldHistory(key, "status");
string previous_status = getElement(status_history, size(status_history)-3);
if(return previous_status !== STATUS_OPEN) {
return false;
} |
Cascading select comparer
...
Code Block |
---|
title | Cascading select comparer |
---|
|
//Condition Cascading select comparer
if (length(#{CASCADING 1}) == 0 && length(#{CASCADING 2}) == 0) { //both cascading select are empty
return true;
}
if (#{CASCADING 1} == #{CASCADING 2}) {
return true;
}
return false; |
...
Code Block |
---|
title | Cascading select comparer |
---|
|
//Condition Cascading select comparer
if (length(#{CASCADING 1}customfield_10000) == 0 && length(#{CASCADING 2}customfield_10001) == 0) { //both cascading select are empty
return true;
}
if (#{CASCADING 1} == #{CASCADING 2}) {(customfield_10000 == customfield_10001) {
return true;
}
return false; |
...
Code Block |
---|
title | Condition based on regular expression |
---|
|
//Condition based on regular expression
if(return matches(Combo, "accepted(.)(\\\\d+\\\\.?){10}(.)[a-z]+(-)(\\\\d+\\\\.?)")) {
return true;
}
return false; |
Condition based on linked issues
...
Code Block |
---|
title | Condition on linked issues |
---|
|
//Condition on linked issues
if(isNull(getLinkedIssues(key)) || size(linkedIssues(key))==0) {
return false;
}
return true; |
Condition on non-linked issue
...
Code Block |
---|
title | Condition on non-linked issue |
---|
|
//Condition on non-linked issue
if(isNull(getLinkedIssues(key)) || size(linkedIssues(key))==0) {
return true;
}
return false; |
...
Code Block |
---|
title | Condition based on mathematical expression |
---|
|
//Condition based on mathematical expression
number n = rand() + e();
return if(n >= 1) {
return true;
}
return false; |
To be more specific, rand() generates a number in interval [0, 1] and e() is the Euler constant. The workflow condition will be not available if the sum of the random number and the Euler constant is less than 1.
...
Code Block |
---|
title | Except assignee condition |
---|
|
//Except assignee condition
if(return currentUser() == assignee) {
return true;
}
return false; |
Except reporter condition
...
Code Block |
---|
title | Except reporter condition |
---|
|
//Except reporter condition
if(return currentUser() == reporter) {
return true;
}
return false; |
Condition based on boolean expression
...
Decide if a transition should be disabled using string equality.
Code Block |
---|
return (currentUser() == "admin"); |
Use currentUser() to get the current logged in user.
...
Use created and updated to compare 2 dates.
Code Block |
---|
return (created < updated); |
To get the currentDate, you can use currentdatecurrentDate() routine.
Condition based on comparison of numeric fields
...
Code Block |
---|
interval tstSpent = "1d 4h";
interval tstEstimate = "1w";
interval tstRemaining = "3d 4h";
return (tstEstimate == (tstSpent + tstRemaining)); |
In the example above it is used the addition between tstSpent and tstRemaining, but the user can also use the subtraction between tstEstimate and any of the other 2 intervals.