Schedule and send generated export (csv) report to Users

What are the steps to generate schedule a report and send exported (csv) results to specific email ids?

  • It depends on the version of sugar you are running. On Professional, for example, each user has to go to the report and schedule it for themselves. In Enterprise/Ultimate, as of v9 I believe, you can add multiple users to a scheduled report.


    See if this helps (Note that the link is for Enterprise v10.2) you may need to change version if you are running something different:

    https://support.sugarcrm.com/Documentation/Sugar_Versions/10.2/Ent/Application_Guide/Reports/#Scheduling_Reports

    FrancescaS

  • To schedule and send as CSV you'll need to use Advanced Reports, only not available in Pro version

    .

    CRM Business Consultant

  • You can also create a custom scheduler, that runs a SugarQuery, generates and output and emails it as a csv attachment.

    There ia a fair amount of coding involved, and you would have to code it so it emails by exact email address, by a User's Team (email everyone in a given team) or some other similar criteria.

    For example, I have a daily report that runs to report any errors in our Sync with ERP

    custom/Extension/modules/Schedulers/Ext/ScheduledTasks/

    I created a custom scheduler job that queries some data, gets each result as a row and puts the results in a csv with headers which is then attached to an email and sent

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    <?php
    array_push($job_strings, 'accountSyncErrorReporting');
    function accountSyncErrorReporting(){
    include_once('custom/entry_points/Utils/send_group_email.php');
    global $db;
    $send = false; //send only if there is something to report
    $query = "select * from ora_sugar_accounts_stg where comments is not null and integration_status = ?";
    $conn = $db->getConnection();
    $stmt = $conn->executeQuery($query, array('sync_failed'));
    if(!empty($stmt)){
    $headers = array();
    //the csv goes in a temp directory we have in our sugar cache directory
    if(!is_dir(sugar_cached('temp'))){
    sugar_mkdir(sugar_cached('temp'));
    }
    //create csv attachment with results
    $filename = 'AccountSyncErrorReport_'.date("Ymd").'.csv';
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     

    The send Email code quite old and probably could use a revision and improvements but you know how it goes, if it works, you never have the time to go back and make it better... ;)

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    <?php
    //Function to send Email message
    function sendGroupEmail($ToEmailAdd, $FromEmailAdd, $FromEmailName, $EmailSubject, $EmailBody, $CcEmailAdd = array(), $attach='') {
    include_once('modules/Mailer/MailerFactory.php');
    global $sugar_config;
    $To = array();
    $Cc = array();
    if(is_array($ToEmailAdd)){
    $To = $ToEmailAdd;
    }else{
    $To = explode(';',$ToEmailAdd);
    }
    if(is_array($CcEmailAdd)){
    $Cc = $CcEmailAdd;
    }else{
    $Cc = explode(';',$CcEmailAdd);
    }
    try{
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Hope this helps you find a solution that works for you! 
    FrancescaS

  • This functionality is now available in the recent Q1 2022 release. You can read more about this functionality in the Application Guide.