In a punctual case, I could solve it according to your proposal (thanks!), but the situation repeats every time we include the creation of a new record of any module via code: the created record does not inherit the security groups of the parent record.
It seems reasonable that this works automatically, just like when we create a record using EditView or quickCreateView.
Perhaps this behavior has never been included in SecuritySuite because the developers have not considered it appropriate, if so, I would like to know why.
Yes, I have seen that this behavior is defined in the /SecurityGroups/SecurityGroup.php file.
However I think the dependency on the existence of $_REQUEST is unnecessary.
This code could be modified so that the inheritance of the security groups of the parent record does not depend on the existence of $_REQUEST ['relate_to'] and $_REQUEST ['relate_id']. In this way, inheriting the parent record would also work when creating a record through code.
Apart from the fact that we should not modify core files … Would it be a problem for the inheritance mechanism to work also when $_REQUEST ['relate_to'] and $_REQUEST ['relate_id'] (or other $_REQUEST[...]) do not exist?