IMPORTANT NOTE: these codes would work only if eazyBI is used for Jira Cloud. For more info please see eazyBI support comments (in the comments section of this post)

eazyBI does not track the change history for those fields by default. However, you may add those fields to data import. This solution requires changes in advanced settings and account import options.

1) In advanced settings you may add this piece of code to fetch changes in the “Original estimate”:

[jira.customfield_org_est_h_change]
name = "Original estimated hour changes"
data_type = "decimal"
measure = true
multiple_dimensions = ["Time"]
javascript_code = '''
ortimeEstimateHistory = new Array();
if (issue.changelog && issue.changelog.histories) {
  first_change = true;
  for (var i=0; i < issue.changelog.histories.length; i++){
    var history = issue.changelog.histories[i];
    for (var a=0; a < history.items.length; a++) {
      var item = history.items[a];
      if (item.field == "timeoriginalestimate") {
        if (!item.from) item.from = 0;
      	if (first_change ) {
      		ortimeEstimateHistory.push(issue.fields.created.substring(0, 10) + ',' + parseInt(item.from)/3600);
      		first_change = false;
      	}
      	change=item.to - item.from;
        ortimeEstimateHistory.push(history.created.substring(0, 10) + ',' + parseInt(change)/3600);
      }
    }
  }
}
if ((!ortimeEstimateHistory || !ortimeEstimateHistory[0])&& issue.fields.timeoriginalestimate) {
 	ortimeEstimateHistory.push(issue.fields.created.substring(0, 10) + ',' + parseInt(issue.fields.timeoriginalestimate)/3600);
}
if (ortimeEstimateHistory) {
	issue.fields.customfield_org_est_h_change = ortimeEstimateHistory.join("\n");
}
'''

In import options select import as a Measure for custom field “Original Estimate”.
In reports, you may use this custom field measure “Original Estimated hour changes” along with dimension “Time” to see the value changes in a time.

2) In advanced settings you may add this piece of code to fetch previous “Due Date” values:

[jira.customfield_prevous_duedates]
name = "Previous Due dates"
data_type = "string"
javascript_code = '''
var previousDuedate = new Array();
if (issue.changelog && issue.changelog.histories) {
//  first_change = true;
  for (var i=0; i < issue.changelog.histories.length; i++){
    var history = issue.changelog.histories[i];
    for (var a=0; a < history.items.length; a++) {
      var item = history.items[a];
      if (item.field == "duedate" && item.from) {
        previousDuedate.push(item.from);
        issue.customfield_1 = previousDuedate; // test
      }
    }
  }
}
if (previousDuedate) {
	issue.fields.customfield_prevous_duedates = previousDuedate.join(",");
	issue.customfield_2 = issue.fields.customfield_prevous_duedates; // test
}
'''

In import options select import as a property for custom field "Previous due dates“.
In reports, you may use this issue property “Issue Previous due dates” which represents previous due dates separated by a comma.

3) If you only need to track the first filled “Due Date” to compare the first and the last as Date object

[jira.customfield_prevous_duedates]
name = "Previous Due dates"
data_type = "date"
javascript_code = '''
var previousDuedate = null;
if (issue.changelog && issue.changelog.histories) {
  for (var i=0; i < issue.changelog.histories.length; i++){
    var history = issue.changelog.histories[i];
    for (var a=0; a < history.items.length; a++) {
      var item = history.items[a];
      if (item.field == "duedate" && item.from) {
        previousDuedate = item.from;
        i =  issue.changelog.histories.length;
        a =   history.items.length;
      }
    }
  }
}
if (previousDuedate) {
  var d = previousDuedate.split('-');
  issue.fields.customfield_prevous_duedates = new Date(d[0],--d[1],d[2]);
  //issue.fields.customfield_previous_duedates = previousDuedate;

}
'''

Many many thanks to the eazyBI support team! You are awesome!

Example using the DueDate and the previous DueDates.

eazybiduedate

Posted by:.

11 replies on “How to track “Original Estimate” and “Due Date” changes with eazyBI and JIRA

    1. Hey William,

      issue.customfield_1 = previousDuedate; // test
      and
      issue.customfield_2 = issue.fields.customfield_prevous_duedates; // test

      are only “test” lines to see in the issue Json the result expected. (Useful when we debug javascript code in the importation section of EazyBI)
      You can avoid it!

      Regards

      Like

    1. Hi Cindy, yes It works.
      In Measures dimension you must have something like this:

      To get DueDate:
      [Measures].[Issue due date]

      To get previous DueDate field:
      [Issue].CurrentHierarchyMember.get(‘Previous Due dates’)

      To get previous DueDate we can do something like this:
      IIF (not IsEmpty([Measures].[Issue Previous Due dates]),
      [Measures].[Issue Previous Due dates],
      [Measures].[Issue due date]
      )

      Like

  1. Hey Mr.Addon,

    Thank you for sharing insights on how eazyBI can be used.

    It would be great if you could add to your post that these codes above would work only if eazyBI is used for Jira Cloud.

    When eazyBI is used for Jira Server, not all changelog is available for import (and then Javascript is useless to find changes in due dates and original estimated hours).
    As a workaround Server users can try using Jira Misc calculated fields or Scripted fields:
    https://docs.eazybi.com/eazybijira/data-import/data-from-jira-and-apps/jira-misc-custom-fields#JiraMiscCustomFields-Previousduedates

    Martins / eazyBI support team

    Liked by 1 person

Leave a comment