Scheduled report execution ignoring conditions.

Josh Evans
Tera Contributor

Hello,

 

I am trying to get a report to send every hour if there are 5 or more records in it. I have tried several different configurations of this, but regardless of what condition script I try it always sends regardless. See screenshots for different attempts at scripts.

 

Any assistance with what I may be doing wrong is appreciated.

 

Thanks!

 

script screenshot 1.PNG

script screenshot 2.PNG

1 ACCEPTED SOLUTION

stevemac
Tera Guru

Did some testing in San Diego Patch 8

  • In the Scheduled Report
    • ensure the subject field has a value
    • ensure the Run As user has necessary roles to read the table / records
  • Set the system property glide.security.sandbox_no_logging to false (at least in your sub-prod environment) so you can see logging statements
  • Confirm the recipients have notifications enabled

The following conditional script is working

 

var conditionCheck = false;
var encodedQuery = 'active=true^assignment_group=0c43a02f6f9875009efada55eb3ee40e';
var ga_inc = new GlideAggregate('incident');
var recordCount = 0;
ga_inc.addEncodedQuery(encodedQuery);
ga_inc.addAggregate('COUNT');
ga_inc.query();
if (ga_inc.next()){
	recordCount = ga_inc.getAggregate('COUNT');
	if (recordCount > 3) {
		conditionCheck = true;
	}
}
gs.log(recordCount);
gs.log(conditionCheck);
answer = conditionCheck;

 

 
I tested to ensure it ran when count of records was greater than 3 and did not run when count of records was less than the threshold 

View solution in original post

15 REPLIES 15

Hi Steve,

 

This script has worked after testing with both conditions, thank you so much for your help!

 

Josh