Scheduled reports - Every month instead of every 4 weeks

Hello,

My problem is simple : we want to schedule a report to be send every month and not every 4 weeks.

I am sure we are not the only one to face this issue but, today, I don't find an easy well to solve it.

Best wishes,

Fred

Parents
  • When you add 

    $app_list_strings['reportschedule_time_interval_dom']['2629800'] = "Every 1/12 year";

    to a custom/Extension/application/Ext/Language/en_us.xxxx.lang.php file you will get an interval equal to
    365,25 * 24 * 60 * 60 / 12 = 2629800 (sec)

    With that interval you divide the year in 12 parts of equal length.

    :-) :-) :-)

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    hkuske@sugarcrm.com
    SugarCRM Deutschland GmbH

  • Hello and ,

    thank you for your feedback but 1/12 of a year is differrent then the 1st (or the 15th of a month) and we would like to keep on working with core report scheduler.

    So I would rather find a way to override the getNextRunDate from modules\ReportSchedules\ReportSchedule.php in order to manage another type of "dropdown key" (instead of having only duration, maybe other textual key)

    Fred

  • I gave this some more thought... 

    The interval used in calculating the getNextRunDate is an integer, a number of seconds, so it's useless for what you are trying to do.

    As you said, the logical thing would be to extend or override the getNextRunDate.

    I do NOT think this will work well at all but I'll share anyway just as a fun discussion:

    The only way I can think of to try and modify the getNextRunDate:

    Add a custom dropdown field to the ReportSchedules module to override the interval. Tricky because ReportSchedules are not in Studio, so you would have to do so in code, potentially not part of the Extension Framework?

    Let's call the field something like RepeatTypeOverride to make it obvious.

    Define a new dropdown with the values you need, something like: 

    "FDM" => "Each First Day of the Month",

    "LDM" => "Each Last Day of the Month"

    extend the getNextRunDate method in the ReportSchedule class within the framework - and I don't know if you can - to check if RepeatTypeOverride has a value, if it does then see what it is and do the calculation to update the time_interval to whatever number of of seconds until the next desired run

    It's clunky but it might work...

    So if FDM, something like:

    $d = new DateTime();
    $date = $d->modify( 'first day of next month' );
    echo $date->format('Y-m-d H:i:s');

    Will give you the date timestamp of this time on the first of next month.

    It's then a question of calculating the number of seconds between that date-timestamp and the current date-timestamp and using that to update the interval... 

    You should probably also extend the save method to set the appropriate time interval when the scheduler is first saved or updated, else the first run will not be what might be expected.

    As I said, it's clunky... very clunky...

    Good Luck, I look forward to seeing if you find a solution.

    FrancescaS

Reply
  • I gave this some more thought... 

    The interval used in calculating the getNextRunDate is an integer, a number of seconds, so it's useless for what you are trying to do.

    As you said, the logical thing would be to extend or override the getNextRunDate.

    I do NOT think this will work well at all but I'll share anyway just as a fun discussion:

    The only way I can think of to try and modify the getNextRunDate:

    Add a custom dropdown field to the ReportSchedules module to override the interval. Tricky because ReportSchedules are not in Studio, so you would have to do so in code, potentially not part of the Extension Framework?

    Let's call the field something like RepeatTypeOverride to make it obvious.

    Define a new dropdown with the values you need, something like: 

    "FDM" => "Each First Day of the Month",

    "LDM" => "Each Last Day of the Month"

    extend the getNextRunDate method in the ReportSchedule class within the framework - and I don't know if you can - to check if RepeatTypeOverride has a value, if it does then see what it is and do the calculation to update the time_interval to whatever number of of seconds until the next desired run

    It's clunky but it might work...

    So if FDM, something like:

    $d = new DateTime();
    $date = $d->modify( 'first day of next month' );
    echo $date->format('Y-m-d H:i:s');

    Will give you the date timestamp of this time on the first of next month.

    It's then a question of calculating the number of seconds between that date-timestamp and the current date-timestamp and using that to update the interval... 

    You should probably also extend the save method to set the appropriate time interval when the scheduler is first saved or updated, else the first run will not be what might be expected.

    As I said, it's clunky... very clunky...

    Good Luck, I look forward to seeing if you find a solution.

    FrancescaS

Children
No Data