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.

Anonymous
  • 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?

  • If I may add something, this vardefs config is not complete. To have full best behavior you shall better put in vardefs the following : 

    $dictionary['<bean name>']['portal_visibility'] = array(
        'class' => 'Visible',
        'links' => array(
            'Accounts' => '<name of field link for account's relationship>',
            'Contacts' => '<name of field link for contact's relationship>',
        )
    );

    Therefore once a portal user creates a record in the custom module it will be automatically linked to the contact's account and/or to the contact itself.

    (sources : client/portal/api/ModulePortalApi.php, data/visibility/portal/Context.php, src/Portal/Session.php)

    best regards,

    Alexandre

  • Hi Tony Romano,

    Correct, for a non-customised system, the Role that drives the portal permissions for all portal modules (except for the logged in portal user own Contact's profile), will only allow creation of records and not editing of existing records.

    As an example, if you set the permission to "read only" for a field for the portal Role of the Cases module, it will prevent all portal users from setting that field upon record creation (as no editing is allowed).

    For new modules that are added to the portal through customisations, the same behaviour would apply at this stage. Can it be customised? Yes of course, but it might not be as immediate as it sounds.

    Please do feel free to propose enhancement requests via our support portal if you think all customers might benefit for specific changes to the framework around the functionality you are describing.

    I would recommend as a next step to read the following two links to understand in more details how the portal currently works:

    1. https://support.sugarcrm.com/Documentation/Sugar_Versions/9.3/Serve/Portal_User_Guide/ 
    2. https://support.sugarcrm.com/Documentation/Sugar_Versions/9.3/Serve/Portal_Deployment_User_Guide/ 

    Hope it helps with your enquiry

  • So Enrico Simonetti are you saying a custom module in portal cannot have option for editing fields by users?

  • I'm glad this post was useful for you!

    A studio config option would be great, I agree. I will try to influence the addition internally at SugarCRM, but it would go a long way if you contacted support and made an enhancement request. In the meantime, this code example will hopefully help folks.