EazyBi First update of an issue

Hi there,

i need to find out how to get the first touch of an issue from the issue history doesn’t matter if it’s a transition a field update or comment.

i already got this but it doesn’t give me any returns.

[jira.customfield_firstupdate]
data_type = “integer”
measure = true
name = “First Update”
javascript_code = ‘’’
var customfieldChangeDate;
var updated;
var firstupdate = “false”;
if (issue.changelog && issue.changelog.histories && issue.changelog.histories.length >= 1) {
var histories = issue.changelog.histories;
for(history in histories){
if (firstupdate == “false”) {
firstupdate = true;
updated = history.created;
}
}
customfieldChangeDate = (Date.parse(updated) - Date.parse(issue.fields.created)) / 1000 / 60 / 60;
}

issue.fields.customfield_firstupdate = customfieldChangeDate;
‘’’
i need it with this format f.ex. 1h 30m or 72h 30m

we also got a bot that updates the issue so it would be great if i can get the author. The function history.author.name doesn’t work:/

I also try it with a formular, but it gives me not the correct information
Avg(
Filter(
Descendants([Issue].CurrentMember, [Issue].[Issue]),
[Measures].[Issues created] > 0),
DateDiffDays(
[Issue].CurrentMember.get(‘Created at’),
[Issue].CurrentHierarchyMember.get(‘Updated at’))
)

Regards,
Ricardo

1 Like

I updated the script and some issues are correct and other not.

[jira.customfield_firstupdate]
data_type = “integer”
measure = true
name = “First Update”
javascript_code = ‘’’
var customfieldChangeDate;
var updated;
var firstupdate = “false”
var author;
var link = “true”;
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(firstupdate == “false” && history){
for (var n = 0; n < history.author.length; n++) {
author = history.author[n].name
}
for (var a = 0; a < history.items.length; a++) {
var items = history.items[a]
if(items.name == “Link” && items.toString.contains(“OWSUP”)){
link = “false”
}
}
if(link != “false”) {
firstupdate = “true”;
updated = history.created;
customfieldChangeDate = Math.floor((Date.parse(updated) - Date.parse(issue.fields.created)) / 1000 / 60);
}
}
issue.fields.customfield_firstupdate = customfieldChangeDate;

}
}

‘’’
time_unit = “minutes”

I solved by myself.

here for the community:

[jira.customfield_firstupdate]
data_type = "datetime"
name = "First Update"
javascript_code = '''

var created;
var author;
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];
for (var n = 0; n < history.author.length; n++) {
author = history.author[n].name
}
if(author != "a-cismr2d2"){
created = history.created;
break;
}
}
issue.fields.customfield_firstupdate = created;
'''

and as a measure you need to add this

NonZero(Avg(
  Filter(
    Descendants([Issue].CurrentMember, [Issue].[Issue]),
    [Measures].[Issues created] > 0),
    DateDiffMinutes(
      [Issue].CurrentHierarchyMember.get('Created at'),
      [Issue].CurrentHierarchyMember.get('First Update'))
))

The Formation has to be “Minutes”

Keep in mind that you also have to add some customfields that you also wanna track in the history. You have to import all the fields that you wanna got from the history in the source data. Here an example for the customfields:

[jira.customfield_16207]
dimension = true
changes = true
separate_table = true

Regards,
Ricardo

Hi @ric2791!

It’s great that you solved the problem and posted the solution here!

I wanted to add that you can also calculate the minutes from created to the first update already in JavaScript. There is an example with DateDiff calculation for the duration interval dimension in JavaScript here https://docs.eazybi.com/eazybijira/data-import/custom-fields/javascript-calculated-custom-fields#JavaScriptcalculatedcustomfields-Customcalculatedfieldasanintervaldimension.

So, instead of importing DateTime, you would import a number that would be minutes. And for the formula, you would add something similar to this

...
(Date.parse(created) - Date.parse(issue.fields.created)) / 1000 / 60 ;
...

Lauma / support@eazybi.com