Scheduled report doesn't send mail

hello everyone. i’m setting up my first scheduled report but when the cron starts, php log give me this error

[23-Sep-2020 22:06:30 UTC] PHP Notice: Undefined index: aor_email_to_list in C:\Siti\KemperCRM\modules\AOR_Scheduled_Reports\emailRecipients.php on line 49
[23-Sep-2020 22:06:30 UTC] PHP Notice: Undefined index: email_to_type in C:\Siti\KemperCRM\modules\AOR_Scheduled_Reports\emailRecipients.php on line 61

what should i do? no mail is sent

Hi,

It looks like those are PHP Notices, so I wouldn’t expect it to affect functionality too much

Does anything similar appear in the SuiteCRM.log file at the time of the Scheduled Report sending?

It would also be worth checking your Email settings, to ensure that the CRM is able to send emails without issue
(found in Admin->Email Settings)
If you run a “Sent Test Email”, do you receive a Test mail at the specified address?


Also, to try and replicate, which SuiteCRM Version are you running?

Also, what have you selected as the recipients of the Scheduled Report?
(ie: Users/Groups/Manually entered Email addresses)

So. suitecrm version:

Version 7.10.22

Sugar Version 6.5.25 (Build 344)

email setting is working because i recive the email test

when i create the scheduled report, i add an email and a user as target of the report. when i save i get in php error log:

[24-Sep-2020 15:21:25 UTC] PHP Notice: Undefined index: aor_email_to_list in C:\Siti\KemperCRM\modules\AOR_Scheduled_Reports\emailRecipients.php on line 49
[24-Sep-2020 15:21:25 UTC] PHP Notice: Undefined index: email_to_type in C:\Siti\KemperCRM\modules\AOR_Scheduled_Reports\emailRecipients.php on line 61
[24-Sep-2020 15:21:25 UTC] PHP Notice: Undefined index: email_to_type in C:\Siti\KemperCRM\modules\AOR_Scheduled_Reports\emailRecipients.php on line 61

and 0 error on suitecrm log

when the scheduler start i got 0 problem on suitecrm log and a bunch of notice on phperrors

the most near of my issue i think is

[24-Sep-2020 15:29:00 UTC] PHP Notice: Undefined index: cc in C:\Siti\KemperCRM\modules\AOW_Actions\actions\actionSendEmail.php on line 361
[24-Sep-2020 15:29:00 UTC] PHP Notice: Undefined index: bcc in C:\Siti\KemperCRM\modules\AOW_Actions\actions\actionSendEmail.php on line 361

but still no mail sent

still have this issue. any idea?

Hey,

I’ve installed 7.10.22 to try to replicate, but had no luck.

I get similar PHP notices in my error_log, but the scheduled report seems to send out without issues.

If you go to Admin->Schedulers
Then click into the “Run Report Generation Scheduled Tasks” job record

If you expand the “Job Log” what contents does it have?
Is it running at the same time as cron runs?
Also, what value is in the “Last Successful Run” field?

It could be that the job is stuck, or is simply not running for some reason


If the "Run Report Generation Scheduled Tasks" is not running, it may be worth checking some of the other scheduled jobs, to see if they are running on time.

Seems all good except the “last run” on the scheduled report

the problem is “last successful run” is empty on the scheduled report. i don’t know what i’m missing. All other workflow are working without any kind of problem. but the scheduled report nope. Where i can dig in the code to see what is happening?

1 Like

FOUND IT!!!
in AOR_Scheduled_Report.php on line 197

there is

 if (empty($this->last_run) && $cron->isDue($date)) {
        return true;
    }

this actually never trigger. i don’t know why. but now i placed

if (empty($this->last_run) || $cron->isDue($date)) {
return true;
}

and now actually works

no, i was joking. this doesn’t fix the thing.

ok i found the real fix. same file

if ($next< $date) {
doesn’t work
if ($next->format('Y-m-d H:i:s') < $date->format('Y-m-d H:i:s')) {
This fix the problem

Where exactly is that? I can’t find it in AOR_Scheduled_Reports.php

If those are DateTime object, the comparison operator should work correctly. But maybe one of them is a string? Or doesn’t handle timezones correctly?

this is my shouldrun function

public function shouldRun(DateTime $date,$last_run=null)
{
	$log_filename = "C:\Siti\KemperCRM\modules\AOR_Scheduled_Reports\log";
	if (!file_exists($log_filename)) 
	{
		
		// create directory/folder uploads.
		if (!mkdir($log_filename, 0777, true)) {
			die('Failed to create folders...');
		};
	}	
	$log_file_data = $log_filename.'/log_' . date('d-M-Y') . '.log';
	//file_put_contents($log_file_data, print_r($date,1)."\n", FILE_APPEND);
    global $timedate;
	
    if (empty($date)) {
        $date = new DateTime();
    }
    $cron = Cron\CronExpression::factory($this->schedule);
//	file_put_contents($log_file_data,"schedule:". print_r($date,1)."\n", FILE_APPEND);
    if (empty($last_run) && $cron->isDue($date)) {
        return true;
    }
    $lastRun = $timedate->fromDb($last_run);
	//file_put_contents($log_file_data,"this var dump: ". var_dump($this,1)."\n", FILE_APPEND);
//	file_put_contents($log_file_data,"cron var dump: ". var_dump($cron,1)."\n", FILE_APPEND);

    $next = $cron->getNextRunDate($lastRun);
	
	/*file_put_contents($log_file_data,"date_controllo: ". print_r($date->format('Y-m-d H:i:s'),1)."\n", FILE_APPEND);

	file_put_contents($log_file_data,"next_controllo: ". print_r($next->format('Y-m-d H:i:s'),1)."\n", FILE_APPEND);
	
	file_put_contents($log_file_data,"last_run controllo: ". print_r($last_run,1)."\n", FILE_APPEND); */
	
	$correct_last = date('Y-m-d H:i:s', strtotime('+2 hours', strtotime($last_run)));
	
	//file_put_contents($log_file_data,"last_run correct controllo: ". print_r($correct_last,1)."\n \n \n", FILE_APPEND);
	
	if((empty($last_run)))
		return true;
	
	if($correct_last > $next->format('Y-m-d H:i:s') )
		return false;
	
	
    if ($next->format('Y-m-d H:i:s') < $date->format('Y-m-d H:i:s')) {
		
        return true;
    }else{
	//	file_put_contents($log_file_data,"date_controllo: ". print_r($date,1)."\n", FILE_APPEND);

	//	file_put_contents($log_file_data,"next_controllo: ". print_r($next->date,1)."\n", FILE_APPEND);
	return false;
	}
    return false;
}

there are some file_put_contents but actually for me works.

i had to add a new parameter “$last_run”, because the function itself give me always emty, so i had to pass the correct value by parameter