How to get a Count of Date changes

I need a way to show the amount of times a Date field was changed/updated from its original Date.

If a Due date was created 1/1/2019 but pushed out 3 different times and is lastly showing 6/1/2019, I need the report to show the number of times it was changed, 3 being the answer.

Your assistance is greatly appreciated.

Hi @BRoger,

If date changes are fixed in the issue change history and available in the issue JSON object retrieved by eazyBI, then you may import this information in eazyBI as JavaScript calculated custom field.

For example, if you have some custom date field then you may use custom field definition with JavaScript like this:

[jira.customfield_xxx_changes]
name = "Number of XXX date changes"
data_type = "integer"
measure = true
javascript_code = '''
var fieldChanges = 0;
//go through issue change history items
if (issue.changelog && issue.changelog.histories && issue.changelog.histories.length > 0) {
  var histories = issue.changelog.histories;
  for (var i = 0; i < histories.length; i++) {
    var history = histories[i];
    if (history.items && history.items.length > 0) {
      for (var n = 0; n < history.items.length; n++) {
        var item = history.items[n];
        //looking for changes incustom field
        //enter the custom field name in "XXX Date"
        if (item.field == 'XXX Date' && item.from) {
          fieldChanges++;
        }
      }
    }
  }
} if(fieldChanges > 0) {
  issue.fields.customfield_xxx_changes = fieldChanges;
}
'''

For more details on how to definer a JavaScript custom field and check what data are available for eazyBI in JSON format, please, see the documentation: https://docs.eazybi.com/eazybijira/data-import/custom-fields/javascript-calculated-custom-fields.

Unfortunately, this solution won’t work for Due Date changes on Jira Server as eazyBI does not retrieve this information. In that case, you may calculate due date changes with some scripted field and then import them into eazyBI (https://docs.eazybi.com/eazybijira/data-import/data-from-jira-and-apps/jira-calculated-and-scripted-custom-fields#Jiracalculatedandscriptedcustomfields-Duedatechanges).
Related community topics on due date changes:

Best,
Zane / support@eazyBI.com

Hi Zane, thank you for the response. I will give this a try!

Hi Zane

I used these code that you explained in the comment but when I would like to see the result in easy bi is empty . Any idea why ? . I tested this code in javascript code and don´t show me error.

[jira.customfield_due_changes]
name = “Number of due date change”
data_type = “integer”
measure = true
javascript_code = ‘’’
var fieldChanges = 0;
//go through issue change history items
if (issue.changelog && issue.changelog.histories && issue.changelog.histories.length > 0) {
var histories = issue.changelog.histories;
for (var i = 0; i < histories.length; i++) {
var history = histories[i];
if (history.items && history.items.length > 0) {
for (var n = 0; n < history.items.length; n++) {
var item = history.items[n];
//looking for changes incustom field
//enter the custom field name in “XXX Date”
if (item.field == ‘Due date’ && item.from) {
fieldChanges++;
}
}
}
}
} if(fieldChanges > 0) {
issue.fields.customfield_due_changes = fieldChanges;
}
‘’’

@Carlos_Javier_Prieto there are several reasons why this code does not work for the field “Due date”.

  1. Always check the JavaScript code part in the eazyBI before implementing it. This way you can ensure the correct field names and check the outcome on specific issue data: Here are more details on how to do this: Validate the Javascript code before using it in the custom field definition

  2. This approach does not work for due date fields as mentioned in the solution.

    Unfortunately, this solution won’t work for Due Date changes on Jira Server as eazyBI does not retrieve this information. In that case, you may calculate due date changes with some scripted field and then import them into eazyBI (https://docs.eazybi.com/eazybijira/data-import/data-from-jira-and-apps/jira-calculated-and-scripted-custom-fields#Jiracalculatedandscriptedcustomfields-Duedatechanges ).
    Related community topics on due date changes:

Best,
Zane / support@eazyBI.com

Hi Zen,

I followed your instructions to pull a custom filed (SVT_Due_Date) as a measure but In the report it’s empty.

[jira.customfield_duedate_changes]
name = “SVT_Due_DateChanges”
data_type = “integer”
measure = true
javascript_code = ‘’’
var fieldChanges = 0;
//go through issue change history items
if (issue.changelog && issue.changelog.histories && issue.changelog.histories.length > 0) {
var histories = issue.changelog.histories;
for (var i = 0; i < histories.length; i++) {
var history = histories[i];
if (history.items && history.items.length > 0) {
for (var n = 0; n < history.items.length; n++) {
var item = history.items[n];
//looking for changes incustom field
//enter the custom field name in “XXX Date”
if (item.field == ‘SVT_Due_Date’ && item.from) {
fieldChanges++;
}
}
}
}
} if(fieldChanges > 0) {
issue.fields.customfield_SVT_Due_Date_changes = fieldChanges;
}
‘’’
image

Hi @Joshua,

First, check the JavaScript code part in the eazyBI before implementing it. This way you can ensure the correct field names and check the outcome on specific issue data: Here are more details on how to do this: Validate the Javascript code before using it in the custom field definition

I noticed the custom field name in advanced settings (1st line from top) differs from the field name used in code holding the changed values (3rd line from bottom).
customfield_duedate_changes
customfield_SVT_Due_Date_changes
It means you assign the past values to one field but chose another (empty field) for importing data.
To make this work, both custom field names should match.

When updating the advanced settings, make sure to perform double data import for the custom field as described in the documentation: JavaScript calculated custom fields.