How to copy User Roles and Teams normally in sugarcrm14

How do copy User Roles and Teams in sugarcrm14?

normally The copy function only copies default Teams as suggested in the Sugar 14 documentation https://support.sugarcrm.com/documentation/sugar_versions/14.0/ent/administration_guide/users/#Creating_via_Duplication

But when I tried, it did not copy roles and teams from the first user

Tried to remove user modules' custom logic hooks, and check to debug level logs, did not find anything useful

Please suggest

Parents
  • Hi  ,

    We manage to do it by ourself wih hooks and asynchronous jobs to propagate the teams from one parent record to "child" modules, ie from Opportunity record to account, contacts linked to account, meetings linked to contacts linked to account, etC ...

    Here is an example of what we did :

    First we remove the teams : 

    foreach ($data->beanIdList as $idBean) {
                    $bean = BeanFactory::getBean($data->moduleName, $idBean, ['use_cache' => false]);
                    $bean->load_relationship('teams');
                    $bean->teams->setSaved(false);
                    $bean->teams->remove($data->externalTeamIdList);
                }

    Then we add the teams : 

    foreach ($data->beanIdList as $idBean) {
                    $bean = BeanFactory::getBean($data->moduleName, $idBean, ['use_cache' => false]);
                    $bean->load_relationship('teams');
                    $bean->teams->setSaved(false);
                    $bean->teams->add($data->externalTeamIdList);
                }

    Hope this will help you.

    Best regards,

    Enes

Reply
  • Hi  ,

    We manage to do it by ourself wih hooks and asynchronous jobs to propagate the teams from one parent record to "child" modules, ie from Opportunity record to account, contacts linked to account, meetings linked to contacts linked to account, etC ...

    Here is an example of what we did :

    First we remove the teams : 

    foreach ($data->beanIdList as $idBean) {
                    $bean = BeanFactory::getBean($data->moduleName, $idBean, ['use_cache' => false]);
                    $bean->load_relationship('teams');
                    $bean->teams->setSaved(false);
                    $bean->teams->remove($data->externalTeamIdList);
                }

    Then we add the teams : 

    foreach ($data->beanIdList as $idBean) {
                    $bean = BeanFactory::getBean($data->moduleName, $idBean, ['use_cache' => false]);
                    $bean->load_relationship('teams');
                    $bean->teams->setSaved(false);
                    $bean->teams->add($data->externalTeamIdList);
                }

    Hope this will help you.

    Best regards,

    Enes

Children
No Data