What is the common practice to Test script in Servicenow for output?

Max Lin
Tera Contributor

Hi There! 

Basic question. 

Say i read this link https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0827366 for scheduled email report. 

and there is this script in the KB (no errors)

 

How can i test this script in my servicenow to check for output? i googled around, some say use "scripts - background"  (https://<instance>.service-now.com/sys.scripts.do)

 

However the output is blank, it should return true or false so that i could check what is the return..

 

Or is there a better way to test script for the output?

 

Thanks!!!!

 

// This condition should cause the scheduled report to only run on a Tue, Wed and Fri)
// 0=Sunday,1=Monday,2=Tuesday,3=Wednesday,4=Thursday,5=Friday,6=Saturday
var d = new Date();
dayOfWeek = d.getDay();
if(dayOfWeek == 2 || dayOfWeek == 3 || dayOfWeek == 5) {
answer = true;
}
else {
answer = false;
}

 

 

find_real_file.png

Run:

find_real_file.png

 

1 ACCEPTED SOLUTION

Muhammad Khan
Mega Sage
Mega Sage

Hi Max,

 

Replace answer = true; with gs.print('true');

Replace answer = false; with gs.print('false');

 

Hopefully this will at least print true/false.

View solution in original post

1 REPLY 1

Muhammad Khan
Mega Sage
Mega Sage

Hi Max,

 

Replace answer = true; with gs.print('true');

Replace answer = false; with gs.print('false');

 

Hopefully this will at least print true/false.