How to Add Insights to Custom Modules in SuiteCRM?

Hi everyone,

I’m working with custom modules in SuiteCRM and I want to add insights in detail view,
same as how we have it on Opportunities module

I haven’t been able to find a straightforward way to integrate insights into custom modules. Does anyone have experience with this or know the steps required to achieve it?

Search these forums for legacy.module_routing to learn how to change the mode of specific modules.

config/services/module/module_routing.yaml

Check if you have that custom module there and its setting.


   accounts:
      index: true // true means suite 8 view
      list: true
      record: false // false means classic view

This can help if you are trying to implement something similar to it.

How to add an Insight button like v8 modules?

I think if we add ‘sidebarWidgets’ section in our custom module, Insights button will appear. The actual statistics chart can be added if we follow the steps implemented in existing modules.

We can refer existing code from the Accounts module.

There is sidebarWidgets section in detailviewdefs.php and listviewdefs.php in \public\legacy\modules\Accounts\metadata\detailviewdefs.php
with a chartKey value (accounts-past-years-closed-opportunity-amounts)

We have the corresponding data handler for the statistics in
\core\modules\Opportunities\Statistics\Series\PastYearsClosedOpportunityAmounts.php
with key having the chartKey (accounts-past-years-closed-opportunity-amounts)
and implement getData() method that returns Statistic object.

  'sidebarWidgets' => [
          [
              'type' => 'chart',
              'options' => [
                  'toggle' => false,
                  'headerTitle' => true,
                  'charts' => [
                      [
                          'chartKey' => 'accounts-past-years-closed-opportunity-amounts',
                          'chartType' => 'line-chart',
                          'statisticsType' => 'accounts-past-years-closed-opportunity-amounts',
                          'labelKey' => 'LBL_CLOSED_PER_YEAR',
                          'chartOptions' => []
                      ]
                  ]
              ],
              'acls' => [
                  'Accounts' => ['view', 'list'],
                  'Opportunities' => ['view', 'list']
              ]
          ],
          [
              'type' => 'history-timeline',
              'acls' => [
                  'Accounts' => ['view', 'list']
              ]
          ],
      ],

I will try on my machine and update here with the steps. Thanks