Schedule a report daily excluding Friday and Saturday

S_matar
Tera Expert

Hi all 

 

can you please assist if there is a way to Schedule a report daily excluding Friday and Saturday ? 

 

2 REPLIES 2

Lukasz Bojara
Kilo Sage

Hi,

 

You should set up your report to run Daily on the hour you need. Then mark the Condition checkbox. In the script field, you need to write code that will check if the day is Friday or Saturday. The script will run each time when the scheduled time will meet. The last line of the script must evaluate to true or false (not only return it). Also, the script will not be checked if you will try to for execution, it is only evaluated when the schedule is met.

 

This is a script condition:

 

function checkDay(){
	var run = true; // set up varaiable to true so that it will run by default
	var gdToday = new GlideDateTime(); // get current date
	var day = gdToday.getDayOfWeekUTC(); // get the week day numeric value
	
	// check if Friday or Saturday
	if(day == 5 || day == 6) {
		gs.info('Scheduled Report Run: omitted becouse of Friday/Saturday.'); // write to log about omit
		run = false; // change run to false
	}
	
	return run; // return decision
}

checkDay(); // run the funtion, it will evaluate to true or false

 

This is how the schedule should look like:

 

find_real_file.png

 

If my answer helped you in any way, please then mark it as helpful. If this solved your case please mark it as a correct answer. Thank You.

Best regards,

Łukasz

 

Alikutty A
Tera Sage

Hi,

You could execute this by simply adding the following condition in your scheduled report.

var now = new Date();
var day = now.getDay(); 
// do not run on friday or saturday 
if (day != 5 && day != 6) { 
  return true;
}

 

find_real_file.png