Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Breakdown Mapping for Hour of Day PA reporting

RRolling
Tera Guru

Im so close I can feel it!

but I still need some help. I created widget called 'Daily Service Desk Per Hour'

find_real_file.png

The widget should show a breakdown of incidents per hour from the following day.

the issue is the incidents are not created and displayed in the correct column as you can see below.

find_real_file.png

In this example I clicked on the column for incidents opened from 11:00-12:00 but it show opened incidents from 4:00-5:00.

Widget:
find_real_file.png

Breakdown:
find_real_file.png

 

Any help on why the widget doesn't show the correct incidents within the hours of the day?

12 REPLIES 12

Should a function like this work:

var hour = function(){

    var dateOpened = new GlideDateTime(current.opened_at);

    return dateOpened.getHourOfDayLocalTime();

};

hour();

 

Its basically copied from the PA developer article:

https://developer.servicenow.com/dev.do#!/learn/learning-plans/orlando/servicenow_administrator/app_store_learnv2_reportanalytics_orlando_creating_breakdown_scripts_optional

 Or what should I change to display it in columns?

Adam Stout
ServiceNow Employee
ServiceNow Employee

I believe that will work. To be sure, add a debugging line:

var hour = function(){
    var dateOpened = new GlideDateTime(current.opened_at);
    gs.info(current.opened_at + ' - ' + dateOpened.getHourOfDayLocalTime());
    return dateOpened.getHourOfDayLocalTime();

};
hour();

Then you can see in the logs if you are getting the right hour.  For me, it worked when I collected for yesterday then look at yesterday's scores.  I lost some time thinking it wasn't working when I looked at the analytics hub and it showed me the real-time scores as blank (scripts are not supported in real-time).

Hey Adam, 

I am going through a similar issue here,

Could you help me out with the breakdown script as well? 

I currently use hour of day script and its fetching me the data in UTC timezone.

current.opened_at.getByFormat('H'); //this shows all records created in last 30 days but with hour breakdown in UTC

I tried with below script as well to get data in my tz, which it ultimately does, but then i don't see more than half of the records in the report (those that were created after 16:00), which is extremely weird. 

var hour = function(){
var dateOpened = new GlideDateTime(current.opened_at);
return parseInt(dateOpened.getLocalTime().getByFormat('H'));

};
hour();

//this shows me partial records created in last 30 days but with hour breakdown with correct hour in my TZ

// i do have data in my scoresheet, but not in the report