Assign security group to contact on creation

Hi all,

I want to assign a security group on creation to a contact.
I am using SuiteCRM 8.2 and looked at the workflow module but I cannot manage to assign it to a security group.

I am able to do it on creation with users.

Below the workflow of users:

Somebody a clue how I can do this but then for customers?

Hello, I hope this helps you.

Identify the Module: Determine which module you want to target. In this case, it’s the “Contacts” module.

  1. Create a Logic Hook:
  • Navigate to the custom directory in your SuiteCRM installation. If it doesn’t exist, you can create it.
  • Inside the custom directory, create a new directory named custom/modules/Contacts/logic_hooks.php.
  1. Define the Logic Hook: Edit the logic_hooks.php file and define your logic hook. Here’s an example:
$hook_version = 1;
$hook_array = array();
$hook_array['before_save'] = array();
$hook_array['before_save'][] = array(
1,
	'Assign Security Group to Contact',
	'custom/modules/Contacts/AssignSecurityGroup.php',
	'AssignSecurityGroup',
	'assignSecurityGroupToContact'
);
  1. Create the Logic Hook Class: Inside the same custom directory, create a new PHP file named custom/modules/Contacts/AssignSecurityGroup.php. This file will contain the logic for assigning the security group
<?php

if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');


class AssignSecurityGroup
{
	function assignSecurityGroupToContact($bean, $event, $arguments)
	{
    	// Check if it's a new record
    	if ($bean->isNew()) {
        	// Set the security group ID as per your requirement
        	$securityGroupId = 'your_security_group_id';


        	// Assign the security group to the contact
        	$bean->acl_team_set_id = $securityGroupId;
    	}
	}
}

4. Repair and Rebuild: After creating the logic hook, navigate to the Administration panel, go to Repair and click on “Quick Repair and Rebuild” to apply the changes

It should be possible with Workflows… you have to look at “creating a relationship” with a security group.