SecurityGroup in custom module based on related field

in my custom module, I have a relationship with accounts module (primary module: Accounts, and in my custom module I have a field for search account). I would like to set to the record the same security groups associated to the account related. Is this possible? If true, how can I made this?
Thank you so much,

You can use Before Save Logic hook in your custom module to get the related group to account record and assign it to this custom record. But this can only be done by an experienced developer. If you are not a developer you can engage someone to do it.
Check this help:

thank you so much,
I try later the solution with Logic Hooks. My last question is: how can retrieve the account’s security groups?

Thank you

just run this query and get it

$query=SELECT `securitygroup_id` FROM `securitygroups_records` WHERE `record_id`='your-record-id' AND `module`='Accounts' AND deleted=0


If you prefer to use the Beans instead of direct SQL access, you’ll find some bits setting Security groups associations here:


You basically set a relationship between the record and the security group.