Adding a Custom Module to the Customer Portal

Back in September of this year (2019), we held the Developer's Webinar for the 9.2 release of Sugar. During that presentation, I touched on how the Portal can be customized. Among the things illustrated in the webinar was adding a module to the Portal. This is apparently something that you all wanted to know more about. So, let's use this space to focus on just that.

There isn't really much to it - just a few things to remember.

First, you need to create a Module Loadable Package. The package can do pretty much anything you'd like it to do. In the example from the webinar, we had the module display announcements.

Once you have the package ready, add the following vardef to make the new module visible in the portal:

$dictionary['sugar_NAME_OF_YOUR_MODULE']['portal_visibility'] = [
    'class' => 'Visible',
];

If your module will have record or list views, you will need a portal directory under the clients directory. Within that portal folder, be sure to add the appropriate directories and files like so:

<basepath>/sugar_PortalAnnouncements/clients/portal/views/list/list.php

Now upload and install the package in module loader.

To allow this module to be seen/used on the Customer Portal, we must update the permissions for the role that is assigned to our Portal users. In Admin > Role Management find and select the Customer Self Service Portal role.

The next screen will show all of the modules and their permission levels for this role.

Find your new module in the list, and set the permissions that it requires. If you are unsure, base the permissions off of a pre-existing module on the Portal like Bugs. These are the basic settings to make the module appear on the Portal:

  • Access - Enabled
  • Access Type - Normal
  • List - All
  • View - All

For more details on role permissions, refer to the documentation for Setting Module-Level Permissions.

Finally, go to Admin > Sugar Portal > Configure Portal. Your new module will be listed in the Hidden column. To see it in the Portal, simply move it into the Displayed Modules list. And, that's it! Your new custom module has been added to the Customer Portal.

  • I amend my answer to precise one thing : 

    the "class" attribute in the portal_visibility array is to tell Sugar how to handle visibiltiy of records. The two main options are "Visible" or "Generic

    Visible is to let any record in the module visible by all users of portal

    Generic is to filter visible record to only ones related to the user or the account of the user

  • Hi,


    I Would like understand What level of customization is possible in sugar Portal? I want to suggest this to my customer.


    I Would like to create custom module and add that module into Sugar Portal. Is that possible to achieve in SugarCRM latest version?

    I am going create custom relationship with Notes, Documents and Opportunity module is that possible to display into Portal?

    I also create some relate fields, Notes, Comments and attachment fields to custom module is that possible to display into Portal?

    I Would like to create some custom dashlet through code is that possible to display into Portal?



    Regards,
    Bhavesh Patel

  • It's worth noting, in regards to this step:

    If your module will have record or list views, you will need a portal directory under the clients directory. Within that portal folder, be sure to add the appropriate directories and files like so:

    <basepath>/sugar_NameOfYourModule/clients/portal/views/list/list.php

    That the relevant content of those files should use the "portal" key, not the "base" key. For instance, the above list.php would have:

    <?php
    
    $module_name = 'sugar_NameOfYourModule';
    $viewdefs[$module_name]['portal']['view']['list'] = array (

    If you have created your custom module via Module Loader, the equivalent layout file it builds would be

    <basepath>/sugar_NameOfYourModule/clients/base/views/list/list.php

    and would start with:

    <?php
    
    $module_name = 'sugar_NameOfYourModule';
    $viewdefs[$module_name]['base']['view']['list'] = array (

    Copying this file directly to the "portal" directory without updating that reference from "base" to "portal" will cause issues. Similarly, there are stock fields in "base" context that are not available in "portal", such as team-based fields. So these should be removed.

    TLDR; simply copying those Module Builder built view files over to portal will cause problems.

  • Tried this yesterday with 11.1 and was able to show a custom dashlet on the portal start page and to add and list "orders" from that custom module. Nice job to modify the dashlet JSON which describes the start page.

  • Great information! I used this method but I am having a issue in the record list view... I can see all records even the ones that my portal user didn't create. Am I missing something?