get security_group id of a user

Hi to all, i need to automatic assign the security group of a user for anything it creates. I’ve started from opportunities and i’ve created an after_save logic hook. Now, the question is, is there a way to get the id of the security group of the assigned_user_id?
i’ve tried some ways but i still can’t get this id. i need to do a direct query?

thanks to all

If a user is assigned to a security group, any new record created by the user will be automatically assigned to the same security group.

Now If you are trying to achieve something different here are some samples:

How to get current user’s id (The id will help you to load a bean and obtain the relationship to Security Group):

Here a sample on how to add relationships via logic hooks:

1 Like

thanks. worked

Glad it helped!!