First due date
eazyBI for Jira
Import the first due date of an issue. You can use the measure Issues with First due date to count issues by first due date in particular period from "Time" dimension.
Account-specific calculated field
Account specific calculated fields are defined in Source Data → Import options.
Settings for the new field
| Internal name | firstduedate |
|---|---|
| Display name | First Due date |
| Data type | datetime |
| Measure | ✓ |
Custom JavaScript code:
// Get the first due date ever set on the issue
var firstDueDate = null;
// Check changelog for the earliest due date
if (issue.changelog && issue.changelog.histories) {
// Iterate through changelog histories (they are in chronological order)
for (let i = 0; i < issue.changelog.histories.length; i++) {
let history = issue.changelog.histories[i];
for (let j = 0; j < history.items.length; j++) {
let item = history.items[j];
// Check if this is a due date change
if (item.field === "duedate") {
// If there was a "from" value, this is when due date was first set
if (item.from) {
firstDueDate = item.from;
break;
}
else if (item.to) {
firstDueDate = item.to;
break;
}
}
}
// Break outer loop if we found the first due date
if (firstDueDate) {
break;
}
}
}
// If no due date found in changelog, use current due date
if (!firstDueDate && issue.fields.duedate) {
firstDueDate = issue.fields.duedate;
}
return firstDueDate;
Global calculated field
Global calculated fields are defined in eazyBI advanced settings.
Here are the settings for the new field definitions. You should insert the JavaScript (the code given above) below the line // Insert here the Custom JavaScript code. Keep the opening and closing quotation marks. ''', do not delete them.
[jira.customfield_firstduedate] name = "First Due date" data_type = "datetime" measure = true javascript_code = ''' // Insert here the Custom JavaScript code '''