Applying Security Groups to Custom Modules

Hello All,

How does one apply Security Groups to Custom Modules?

The Security Groups Sub Panel did not show up automatically when I created a Custom Module so I added a Relationship but it does not appear to work.

TYIA,

~eric

I found these instrutions, https://suitecrm.com/media/kunena/attachments/20038/SecuritySuite_Documentation_2.1.pdf

in this post, https://suitecrm.com/forum/suitecrm-7-0-discussion/2177-module-builder-security-groups-management

I tried it but the Subpanels don’t show up. Is the following instructions and code still valid?

~eric

Find the generated relationship file in the custom/metadata directory and replace with the following code
(file name formatted YOURCUSTOMMODULE_securitygroupsMetaData.php):

<?php $dictionary["YOURCUSTOMMODULE_securitygroups"] = array ( 'true_relationship_type' => 'many-to-many', 'relationships' => array ( ' YOURCUSTOMMODULE_securitygroups' => array ( 'lhs_module' => 'SecurityGroups', 'lhs_table' => 'securitygroups', 'lhs_key' => 'id', 'rhs_module' => 'YOURMODULENAME', 'rhs_table' => 'YOURCUSTOMMODULE', 'rhs_key' => 'id', 'join_table' => 'securitygroups_records', 'join_key_lhs' => 'securitygroup_id', 'join_key_rhs' => 'record_id', 'relationship_type' => 'many-to-many', 'relationship_role_column' => 'module', 'relationship_role_column_value' => ' YOURMODULENAME', ), ), ); ?>

When I add the custom code then run Rebuild Relationship the Relationship is deleted in the Custom Module.

Not sure what else to do to get this working.

As a work around, for now, I am simply going to re-purpose an unused Module, in this case Bugs, so that I can get this working.

I can see how someday either myself or a client will want this capability though…

~eric

:frowning:

Okay, I was able to get this working, to a point, though a Repair and Rebuild still deletes the Relationship.

First, I created the Many to Many Relationship in Studio.

Then I edited the YOURCUSTOMMODULE_securitygroupsMetaData.php file

Then I ran Repair Roles, NOT Rebuild Relationships.

At first it did not appear to work.

Then I edited the Roles, switch from one permission to another. Then it worked.

Then I ran Quick Repair and Rebuild and the custom Relationship was deleted!

How can we get this change to survive a Repair and Rebuild?

I also noticed that Users have to log out and back in to get new permissions.

~eric