Make a quick vote 🗳 ️How do you refer to SuiteCRM extensions: add-ons or plug-ins? Click here to have your say 👈

Charts not showing on Dashlets (sometimes)

SuiteCRM v 7.12.6

I have read a lot of old posts about charts not showing on dashlets, an error I encountered today.

A fix for me was in modules\AOR_Reports\AOR_Report.php:

    foreach ($linkedCharts as $chart) {
        if ($chartIds !== null && !in_array($chart->id, $chartIds)) {
        $html .= $chart->buildChartHTML($data, $fields, $x, $chartType, $mainGroupField);

Commenting out continue and the chart appears. The array $chartIds was always empty and with continue uncommented the chart isn’t built. I am not sure of the consequence of doing this? Why is the IF there if the buildChartHTML function doesn’t refer to $chartIds?

Further drilling down:

$chartIds is comes from $this->charts, which is populated in the __construct of modules\AOR_Reports\Dashlets\AORReportsDashlet\AORReportsDashlet.php

    $this->charts = !empty($def['charts']) ? $def['charts'] : array();

If $def[‘charts’] is empty there will be an empty $charts array and no chart displayed.

In turn $defs[ ] is populated from the users preferences in modules\UserPreferences\UserPreference.php

        return $_SESSION[$user->user_name.'_PREFERENCES'][$category][$name];

I have checked two CRMs I have, one with the charts working and with not. The $SESSION variables of the one that works has the ‘charts’ array - the other doesn’t:

Does anyone have any idea why the $SESSION variables load up correctly for one and not the other?