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.
hey mr addon! can you explain lines 14 & 21 in the second example? the ones with the remark “// test”. i don’t understand their purpose?
LikeLiked by 1 person
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
LikeLike
Nice write up thanks. Is it possible to use this for history of a Profields field?
thanks
LikeLiked by 2 people
Hi Matt, I have sent your question to Deiser team. They will answer asap!
Thanks for your comment!
LikeLiked by 1 person
thanks for the help
LikeLiked by 1 person
I cannot get the previous due dates to work. I am not getting an error. Just not getting any data in the EazyBI table.
LikeLike
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]
)
LikeLike
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
LikeLiked by 1 person
Thanks Martins for the clarifications. I have added in the top section of the post an important note to clarify this. Best regards
LikeLiked by 1 person
Seems this code works for JIRA 8.5.0. I can get timeoriginalestimate changelog from JIRA get issue API endpoint.
LikeLike
OK, eazybi still cannot get timeoriginalestimate changelog even rest api has them.
LikeLike