All eazyBI for Jira eazyBI for Confluence Private eazyBI

Last date when custom field changed

Import the field to find the date when a Jira custom field (which is also imported in eazyBI) was changed the last time for a specific value

Preparation

In eazyBI, it is possible to import single-value select custom field in a separate table with value changes by adding these advanced settings to your custom field (where you place your actual custom field ID instead of NNNNN).

[jira.customfield_NNNNN]
data_type = "string"
dimension = true
separate_table = true
changes = true

Or you can update the field settings through custom field import options by adding the parameters below to the additional advanced settings:

separate_table = true
changes = true

Then, you can import this custom field as a dimension and import value changes in eazyBI. After that, you can define a Javascript calculated custom field or a new calculated field that returns the last date when the custom field was changed to a particular value.

Account-specific calculated field

Account specific calculated fields are defined in Source Data → Import options.

Settings for the new field

Internal name

valuechange

Display nameValue change date
Data type

date 

Measure

Custom JavaScript code:

var customfieldChangeDate;
if (issue.changelog && issue.changelog.histories && issue.changelog.histories.length > 0) {
  var histories = issue.changelog.histories;
  for (var i = histories.length - 1; i >= 0; i--) {
    var history = histories[i];
    if (history.items && history.items.length > 0) {
      for (var n = history.items.length - 1; n >= 0; n--) {
        var item = history.items[n];
        if (item.field == '<Customfield name>' && item.toString == '<Value>') {
          customfieldChangeDate = history.created;
          break; // Exit the inner loop
        }
      }
      if (customfieldChangeDate) {
        break; // Exit the outer loop if a date has been found
      }
    }
  }
}
return customfieldChangeDate;

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 codeKeep the opening and closing quotation marks. ''', do not delete them.

[jira.customfield_valuechange]
name = "Value change date"
data_type = "date"
measure = true
javascript_code = '''
// Insert here the Custom JavaScript code
'''