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.
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;
}
'''
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;
}
‘’’
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;
}
‘’’
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.