Flagged Stories

I would like to build a report to show flagged stories and how long they have been flagged for?

I do not have the option when I import. I believe I would need to do a new calculated field. Can someone provide me that code?

I used the code below but get an error.

[jira.customfield_days_flagged]
name = "Days Flagged Impediment"
data_type="decimal"
measure = true
javascript_code='''

var date_from = Date.parse(issue.fields.created);
var days_flagged = 0.0;
issue.changelog.histories.forEach(function(history){
    history.items.forEach(function(historyItem){
      if (historyItem.field == "Flagged") {
        to = historyItem.toString;
        from = historyItem.fromString;
        if(to.equals("Impediment")) {
          date_from = Date.parse(history.created);
        }
        if (from && from.equals("Impediment")) {
          date_to = Date.parse(history.created);
          days_flagged += (date_to - date_from) / 1000/ 60 /60 / 24 ;
        }
      }
    });
  });
if (days_flagged>0) issue.fields.customfield_days_flagged=days_flagged;
'''

Hello @AnneDixon,

Thank you for posting this question!

Java Script calculated custom field is going through the history of the “Flagged” field; however, eazyBI only has access to the history if it’s being imported.

As a first step, I suggest going to Jira Import options and checking if you have selected the “Flagged” custom field under the Software Custom fields section (as per the screenshot below). Import value changes to track when the issues were flagged.

You can read more about this option in our documentation: Jira Software custom fields

If the issue still persists, could you please share a screenshot of the error you are receiving?

In addition, the code you posted must be added in eazyBI advanced settings: Advanced settings for custom fields

Kind regards,
Marita // support@eazybi.com

@Marita_Norvele The flag option doesn’t appear when I go into the custom fields.

Hi @AnneDixon,

Please check if you can see this function in “General” tab (as per screenshot below)

Best,
Marita // support@eazybi.com