Michael Michael

How to set up scheduled reports in Kreports with SugarCRM CE 6.5

Discussion created by Michael Michael on Dec 5, 2014
After some time trying to figure it out, I finally managed to get scheduled reports working in Kreports V3.06 (paid version with extensions package)  in SugarCRM CE 6.5.16.  This is highly useful for automating report delivery to managers and reps, and can also be used for automatically updating email target lists. Very cool stuff when you can get it working.  I used some of the kreports documentation here, but the rest by following instructions for adding a scheduler, and with help from Christian Knoll (thanks Christian!). 

This may help some of you get it going by referencing the following steps. 

First, we must create a new SugarCRM scheduler by adding some files on the SugarCRM server. 

1. First, I create   custom/Extension/modules/Schedulers/Ext/ScheduledTasks/runScheduledKReports.php with 
<?php
array_push($job_strings, 'runScheduledKReports');
function runScheduledKReports(){
require_once('custom/modules/KReports/Plugins/Integration/kscheduling/kschedulingcronhandler.php');
 $kreportscheduler = new kschedulingcronhandler();
 $kreportscheduler->initializeScheduledReports();
 $kreportscheduler->runScheduledReports();
 return true;
}
?>
2. Then I create 
custom/Extension/modules/Schedulers/Ext/Language/en_us.runScheduledKReports.php with 
<?php
    $mod_strings['LBL_RUNSCHEDULEDKREPORTS'] = 'Run Scheduled KReports';
3. Back inside SugarCRM UI, perform Admin->Repair->Quick Repair and rebuild. 

4. Ensure proper permissions of the files you just created and ensure permissions of custom/modules/Schedulers/Ext/ScheduledTasks/scheduledtasks.ext.php is properly set to be accessed by SugarCRM (this tripped me up for a few hours)

Now, we make some changes in the admin section of SugarCRM and in your favorite KReport. 

5. Add a new scheduler job in Admin-Scheudlers->Create Scheduler.  If the above has worked, you should see "Run Scheduled KReports" in the Job pulldown field when creating your new scheduler record.  I Set the new Kreporter Scheduler to run every minute for testing.   

6. Set up a scheduled report in one of the Kreports,  Edit your favorite Kreport, use the "Integrate" tab, click the light bulb icon to "on" next to Schedule reports.  Set the frequency using crontab format (look it up).  To test, I ask it to send every five minutes by using */5 as the first value, then once confirmed working, I set it to a more reasonable time.  Set the type of report to CSV, PDF, or Excel (snapshot didn't work for me), enter your email address,  save your report, and watch your email. 

This did the trick for me, and I hope it helps you too. 

-Michael 

Outcomes