Ok, so I have roles created and users assigned to those roles however I need to be able to set the security group of a record when it is created based on the current users Security Group for example
Groups: Insurance and Investment and Managers
Managers can see both Insurance and Investment Groups. Managers can also add and modify records. The problem comes in when the manager creates a new record for Insurance or Investment.
If the manager creates a record on the Insurance side it needs to go under the insurance group and for investment it needs to go under investment.
I’m thinking that using a logic hook may be able to do. Any ideas 
I would say an after_save logic hook should do it.
Here’s a snippet of similar code that might help you get a head-start:
$securityTeam = new SecurityGroup();
$securityTeam->retrieve_by_string_fields(array('name' => $group_to_assign ));
if ( $securityTeam->id == null)
$GLOBALS['log']->fatal("Group with the name '" . array('name' => $group_to_assign ) . "' wasn't found!");
$record->load_relationship('SecurityGroups');
$record->SecurityGroups->add($securityTeam->id);
My code is not from a hook so you’ll have to adapt it, but it should be pretty self-explanatory. $record is the record to which you want to assign the group.
1 Like
Perfect, exactly what I was looking for
Thanks for the assist.