Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Here is an example of a calculated custom field "Tickets overdue" which will return 1 if the ticket has a due date and either resolution date is after the due date (for solved tickets) or the due date is in the past (for unsolved tickets). Add to the advanced settings:

Code Block
[customfield_overdue]
name = "Tickets overdue"
data_type = "integer"
measure = true
javascript_code = '''
if (ticket.due_at) {
  var resolutionOrCurrentTimestamp = ticket.metric_set.solved_at ?
    Date.parse(ticket.metric_set.solved_at) : (new Date).getTime();
  if (Date.parse(ticket.due_at) < resolutionOrCurrentTimestamp) {
    ticket.custom_fields.push({id: "overdue", value: 1});
  }
}
'''

Then import "Tickets overdue" custom field as a measure and flex.bi will create measures "Tickets overdue created", "Tickets overdue due" (total of unsolved tickets that are past their due date), "Tickets overdue resolved" (total of solved tickets that were late).

...