Drilling down a report eventually leads to error 500

Hi, 

Hi,

for one of our customers we encounter a strange issue that I can reproduce but I can not pinpoint where it goes wrong. The customer has a report on opportunities module that contains a graph. The filter is as follows:

  • sales stage is one of won / handed over to ops ( this last is a custom stage)
  • offer owner is not empty (offer owner is a text field)
  • date won is between two dates (runtime)
  • product is not empty (runtime)

they have a report dashlet that shows the graph for this report. When they drill down the graph ( aka click the various months ) at a certain point they get a 500 error. What we see in the logs is a message like this:

PHP Fatal error: Uncaught Error: Call to a member function asDbDate() on string in /data/www/crm.encon.be/htdocs/include/generic/SugarWidgets/SugarWidgetFielddate.php:79\nStack trace:\n#0 /data/www/crm.encon.be/htdocs/include/generic/SugarWidgets/SugarWidgetFielddatetime.php(308): SugarWidgetFieldDate->formatDate('Invalid date')\n#1 /data/www/crm.encon.be/htdocs/include/generic/SugarWidgets/SugarWidgetFielddatetime.php(139): SugarWidgetFieldDateTime->get_start_end_date_filter(Array, 'Invalid date', 'Invalid date')\n#2 /data/www/crm.encon.be/htdocs/include/generic/SugarWidgets/SugarWidgetReportField.php(203): SugarWidgetFieldDateTime->queryFilterBetween_Dates(Array)\n#3 /data/www/crm.encon.be/htdocs/include/generic/SugarWidgets/SugarWidgetReportField.php(262): SugarWidgetReportField->queryFilter(Array)\n#4 /data/www/crm.encon.be/htdocs/include/generic/LayoutManager.php(343): SugarWidgetReportField->query(Array)\n#5 /data/www/crm.encon.be/htdocs/modules/Reports/Report.php(1186): LayoutManager->widgetQuery(Array)\n#6 /data/www/crm.encon in /data/www/crm.encon.be/htdocs/include/generic/SugarWidgets/SugarWidgetFielddate.php on line 79, referer: https://crm.encon.be/


The question here is how do I find out which field this message is originating from? Because when I look into the database all date fields are either a valid date or null value which I would expect. I hope someone can help me out here.

  • SugarWidgetFieldDateTime->get_start_end_date_filter(Array, 'Invalid date', 'Invalid date')\n#2

    Did you try creating a exactly new similar report and see if that works? If the issue still persists:

    When you drilldown on a month, the From->To is passed from the browser to the API, and that could be a possible source of the issue, not in the database level. Try checking the API request in the browser's network tab and see if they are being passed correctly, eg:

    
    GET /rest/v11/Reports/report_id/records
    
    ... fields, etc
    
    // Look into these filters:
    group_filters[0][self:date_closed][]: 2020-08-01
    group_filters[0][self:date_closed][]: 2020-08-31
    group_filters[0][self:date_closed][]: month

    If the date is wrong in the browser request - we can then try to narrow it down by checking the if the browser is compatible/try using a different browser/ultimately trying to debug the javascript that is generating the filter. 

  • I would look at the data in the database.  You might have a date that is NULL or 000-00-00 or something like that.

    If you cant find anything there you might be able to narrow it down by changing the code in include/generic/SugarWidgets/SugarWidgetFielddate.php to something like

    protected function formatDate($date)
    {
    $GLOBALS['log']->fatal($date);
    return $date->asDbDate(false);
    }




  • thanks everyone for the update. It seems that it is an excisting issue in the version of sugar we are using (9.x). It will be solved in 10. Many thanks for the help and ideas where to look