Versions Compared

Key

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

...

Go to an issue and this is how the value of the field is the value returned by the script.


That's it.

 

Other Examples

Issue Age

Code Block
interval age = currentDate() - created;
return "This issue is " + age + " old";

...

Code Block
string field_name = "status";
string[] field_history = fieldHistory(key, field_name);
number n = arraySize(field_history);
date startDate; 
if (n > 0) {
 startDate = arrayGetElement(field_history, n - 2);
 return "Current issue has been " + status + " for " + (currentDate() - startDate);
}
return "Current issue has been " + status + " for " + (currentDate() - created);

 

Issue Statuses Count

Code Block
string[] statuses;
string[] statusHistory = fieldHistory(key, "status");
for(number i = 1; i < size(statusHistory); i = i + 2) {
 string statusStr = getElement(statusHistory, i);
 statuses = addElementIfNotExist(statuses, statusStr);
}
return size(statuses);

Image Added

 

Issue Assignees

Code Block
string[] assignees;
string[] assigneeHistory = fieldHistory(key, "assignee"); 
for(number i = 1; i < size(assigneeHistory); i = i + 2) {
 string assigneeName = userFullName(getElement(assigneeHistory, i));
 assignees = addElementIfNotExist(assignees, assigneeName); 
}
return assignees;

Image Added