Fetch report on awa_interaction_work_item table of those records created during business hours

LearnerSN
Tera Contributor

Fetch report on awa_interaction_work_item table of those records created during business hours.

% of Live Agent chats with First Response <= 30 sec, counted only when open during business hours only.

 

2 REPLIES 2

kmohammed
Tera Guru

Hi,

 

You cannot do the business-hours part with a report condition alone - there is no "created during a schedule" operator for sys_created_on in Report Designer. The reliable pattern is to stamp the answer onto the work item when it is created, then report on that field.

 

1. Add a true/false field to awa_interaction_work_item, for example u_opened_in_business_hours.

2. Set it with a before-insert Business Rule (or a Flow triggered on creation) using GlideSchedule against your business-hours schedule (cmn_schedule):

 

var sched = new GlideSchedule();

sched.load('<sys_id of your business hours schedule>');

current.u_opened_in_business_hours = sched.isInSchedule(new GlideDateTime(current.sys_created_on));

 

Using the schedule matters twice over: sys_created_on is stored in UTC, and isInSchedule evaluates the time in the schedule's own time zone, including holidays defined as schedule entries - a simple "hour between 9 and 17" condition gets both of those wrong.

3. Backfill the existing records once with a Fix Script running the same logic over awa_interaction_work_item, otherwise your report only covers chats created after the rule goes live.

4. Build the percentage as a formula (Performance Analytics formula indicator works best for a % KPI, or two reports if you only need counts):

- Denominator: count of awa_interaction_work_item where u_opened_in_business_hours = true

- Numerator: same condition AND first response time <= 30 seconds (use the first-response value already recorded on the work item / its interaction)

- % = Numerator / Denominator x 100

 

With the flag stamped at insert, all of that becomes a normal filter on the table, and the % stays consistent for every consumer of the report instead of each report builder inventing their own "business hours" logic.

 

Regards,

Karimuddin

sanjaygupta
Tera Guru
 

If you want to report the percentage of Live Agent chats that received a first response within 30 seconds, counting only chats created during business hours, I'd recommend using a business-hours flag on the work item.

A normal report filter cannot reliably evaluate whether a record was created within a business-hours schedule, so you can capture that information when the record is created.

Here's how you can approach it:

  • Add a True/False field, such as u_opened_in_business_hours, to the awa_interaction_work_item table.

  • Create a Before Insert Business Rule to check whether the record's creation time falls within your business-hours schedule.

  • Use GlideSchedule with your cmn_schedule record so holidays and time zones are handled correctly.

Example Business Rule script:

var sched = new GlideSchedule();
sched.load('<business_hours_schedule_sys_id>');

current.u_opened_in_business_hours =
    sched.isInSchedule(new GlideDateTime(current.sys_created_on));
  • Backfill existing records using a Fix Script with the same schedule logic.

  • Create a Performance Analytics formula indicator to calculate the percentage:

\[ \frac{\text{Chats with first response <= 30 sec}} {\text{Chats created during business hours}} \times 100 \]

- Use the u_opened_in_business_hours = true condition for both the numerator and denominator.

My recommendation: Use the existing first-response time field if your implementation already captures it. This approach keeps the business-hours logic consistent across reports and avoids repeating complex schedule conditions.

Test the Business Rule and historical backfill in a sub-production instance first.

References:

 
Hope you find this helpful.