Business hours calculations in Triggers:

These methods are time calculations using business hours currently in effect on a ticket. By default, these time calculations will exclude all time periods where the ticket has been put on hold, and/or marked as closed.

 

// calculate deadline 2 hours after created date, within business hours:

var aDeadline = api.CalculateDate(record, record.CreatedDate, 120);

 

// calculate time passed between ticket’s registered & closed dates:

record.u_Duration = api.CalculateDuration(record, record.CreatedDate, record.CloseDateTime);

 

// check whether ticket registered inside/outside business hours, assign to field

record.u_CreatedInBusinessHours = api.IsInsideBusinessHours(record, record.CreatedDate);

 

// check whether time right now is within business hours

var openRightNow = api.IsInsideBusinessHours(record, DateTime.UtcNow);