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.

HeatMap

Greg Wilk
Tera Contributor

Can someone guide me on how to create this heatmap?  I already tried this link - https://docs.servicenow.com/bundle/quebec-it-asset-management/page/use/performance-analytics/task/cr... but the 2nd breakdown list is empty and has no options for me to choose a breakdown.  Can you provide instructions on how to create this particular heatmap.  See photo.  Thanks.

1 ACCEPTED SOLUTION

JP - Kyndryl
Kilo Sage

Hi Greg,

Here's how I would do it with standard reporting (not PA):

 

JPKyndryl_0-1672951418895.png

 

It requires creation of 2 custom fields of Integer type (in the Task table):  u_day_of_month and u_hour_of_day.

These 2 fields will be maintained by the following 2 BRs:

 

JPKyndryl_1-1672951551414.png

 

(function executeRule(current, previous /*null when async*/) {

var gdt = new GlideDateTime(current.sys_created_on);
current.u_day_of_month = gdt.getDayOfMonthLocalTime();

})(current, previous);

 

JPKyndryl_2-1672951690467.png

 

(function executeRule(current, previous /*null when async*/) {

var gdt = new GlideDateTime(current.sys_created_on);
glt = gdt.getLocalTime();
current.u_hour_of_day = glt.getByFormat('HH');

})(current, previous);

 

 

 

 

 

Regards,
JP

View solution in original post

4 REPLIES 4

JP - Kyndryl
Kilo Sage

Hi Greg,

Here's how I would do it with standard reporting (not PA):

 

JPKyndryl_0-1672951418895.png

 

It requires creation of 2 custom fields of Integer type (in the Task table):  u_day_of_month and u_hour_of_day.

These 2 fields will be maintained by the following 2 BRs:

 

JPKyndryl_1-1672951551414.png

 

(function executeRule(current, previous /*null when async*/) {

var gdt = new GlideDateTime(current.sys_created_on);
current.u_day_of_month = gdt.getDayOfMonthLocalTime();

})(current, previous);

 

JPKyndryl_2-1672951690467.png

 

(function executeRule(current, previous /*null when async*/) {

var gdt = new GlideDateTime(current.sys_created_on);
glt = gdt.getLocalTime();
current.u_hour_of_day = glt.getByFormat('HH');

})(current, previous);

 

 

 

 

 

Regards,
JP

Thank you very much.  This worked out and was exactly what I needed!  One question I have though; I noticed once I created the report with your script; It does not backfill all the incidents with "day of month" and "hour of the day".  So for example, I implemented your script yesterday 1/5/23 at 5PM EST and only those tickets going forward are reflecting in the heatmap/report.  But any tickets prior to 1/5/23 at 5PM EST that were created are not appearing.  Is there a way to have that happen?  Thanks again!

JP - Kyndryl
Kilo Sage

Hi Greg

Exact,  as you can see in the 2 BRs,  it is updating the 2 fields on Insert and Update,  so for old records, you will have to update them.

 

Regards,
JP

JP - Kyndryl
Kilo Sage

Hi Greg,

Please mark the solution if you are happy with the result;  this may helps others.

 

Regards,
JP