Help on building a report to track value change history of a custom field

Hi Team,
I need a help on building a report in eazybi to track value change history of a single select custom field.

I have added java scripts in the additional settings as below

As shown in the below screenshots I wanted to build a report


I am not getting any result in the “Issue Value change dates” not sure if I am doing anything wrong.

Below is the report definition attached, please help me with this.

{
“cube_name”: “Issues”,
“cube_reports”: [ {
“name”: “Valvue change history”,
“folder_name”: “LDC Test Folder”,
“result_view”: “table”,
“definition”: {“columns”:{“dimensions”:[{“name”:“Measures”,“selected_set”:[“[Measures].[Issues created]”,“[Measures].[Fit/gAP]”,“[Measures].[Issue Value change date]”,“[Measures].[Issue Value change date old values]”],“members”:}]},“rows”:{“dimensions”:[{“name”:“Issue”,“selected_set”:[“[Issue].[All Issues]”],“members”:[{“depth”:0,“name”:“All Issues”,“full_name”:“[Issue].[All Issues]”,“drillable”:true,“type”:“all”,“expanded”:true,“drilled_into”:false,“removed”:true},{“depth”:1,“name”:“AWSTESTING PROEJCT”,“full_name”:“[Issue].[AWSTESTING PROEJCT]”,“drillable”:true,“key”:“AP”,“expanded”:true,“drilled_into”:false,“parent_full_name”:“[Issue].[All Issues]”},{“depth”:1,“name”:“Sample Kanban Project”,“full_name”:“[Issue].[Sample Kanban Project]”,“drillable”:true,“key”:“SKP”,“expanded”:true,“drilled_into”:false,“parent_full_name”:“[Issue].[All Issues]”}],“bookmarked_members”:}],“nonempty_crossjoin”:true},“pages”:{“dimensions”:[{“name”:“Issue Type”,“selected_set”:[“[Issue Type].[All Issue Types]”],“members”:[{“depth”:0,“name”:“All Issue Types”,“full_name”:“[Issue Type].[All Issue Types]”,“drillable”:true,“type”:“all”,“expanded”:true,“drilled_into”:false}],“bookmarked_members”:,“current_page_members”:[“[Issue Type].[All Issue Types]”]},{“name”:“Time”,“selected_set”:[“[Time].[All Times]”],“members”:[{“depth”:0,“name”:“All Times”,“full_name”:“[Time].[All Times]”,“drillable”:true,“type”:“all”}],“bookmarked_members”:,“current_page_members”:[“[Time].[All Times]”]}]},“options”:{},“view”:{“current”:“table”,“maximized”:false,“table”:{}},“calculated_members”:}
} ],
“calculated_members”: [{“dimension”:“Measures”,“name”:“Issues history”,“format_string”:“#,##0”,“formula”:“Cache(\n NonZero(Sum(PreviousPeriods([Time].CurrentHierarchyMember),\n [Measures].[Transitions to]\n - [Measures].[Transitions from]\n ))\n + [Measures].[Transitions to]\n - [Measures].[Transitions from]\n)”},{“name”:“Issue Value change date”,“dimension”:“Measures”,“formula”:“[Issue].CurrentHierarchyMember.get(‘Value change date’)”,“format_string”:“mmm dd yyyy”},{“name”:“Issue Value change date old values”,“dimension”:“Measures”,“formula”:“[Issue].CurrentHierarchyMember.get(‘Value change date old values’)”,“format_string”:“”},{“name”:“Fit/gAP”,“dimension”:“Measures”,“formula”:“NonEmptyString(Generate(\n Filter(\n Except(Descendants([Fit/Gap Classification].CurrentMember, [Fit/Gap Classification].[Fit/Gap Classification]),\n [Fit/Gap Classification].[(none)]),\n [Measures].[Issues history] \u003e 0\n ), [Fit/Gap Classification].CurrentMember.Name\n))”,“format_string”:“”}]
}

1 Like

Hi @Amzad ,
It appears that you are using JavaScript custom field “Last date when custom field changed” from the eazyBI documentation.
Here are a few observations and suggestions:

  1. Tracking the last change date: The JavaScript custom field, as its name suggests, is designed to track the last date when a custom field value was changed to a specified value. It does not record all the of changes of the customfield.
  2. Placeholder syntax: '<Customfield name>' and '<Value>' in the script are placeholders. Replace these with the actual custom field name and value used in Jira, without the angle brackets “<>” (unless they are part of your actual field name). Remember, the field and value names are case-sensitive and should exactly match those used in Jira.
  3. Single value last change date: The original script is set up to track changes for only one specific value. If your script includes syntax like “<Gap, Fit, Standard>”, it indicates tracking for multiple values, which is not supported in the provided code.

To track changes for multiple values while still capturing only the last date when the custom field changed to one of these values (var targetValues = ['Gap', 'Fit', 'Standard']), you can use the following code. This script will store the last change date when the custom field was set to one of the defined values in the array.

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

[jira.customfield_valuechange]
name = "Fit/Gap value change date"
data_type = "date"
measure = true
javascript_code = '''
var customfieldChangeDate;
var targetValues = ['Gap', 'Fit', 'Standard']; // Array of target values
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];
        if (item.field == 'Fit/Gap Classification' && targetValues.indexOf(item.toString) > -1) {
          customfieldChangeDate = history.created;
        }
      }
    }
  }
}
issue.fields.customfield_valuechange = customfieldChangeDate;
'''

If you want to track all changes, then I would suggest checking this solution:

Best,
Gerda // support@eazybi.com

1 Like