$GLOBALS["db"]->query()  not working in before save logic hook

Hi

  I want to execute an sql statement in the before save logic hook.

I have tried

$GLOBALS['db']->query("UPDATE users SET description='test' WHERE id='27283e5a-8f34-b846-367a-561fbbb4cb54'");

$db = DBManagerFactory::getInstance();

$res = $db->query("UPDATE users SET description='test' WHERE id='27283e5a-8f34-b846-367a-561fbbb4cb54'");

But it is not working.Shijin Krishna@

Parents
  • If you use before save logic hook in module Users, Sugar logic overwrites field [Description].

    You need use this:

    function customHook(&$focus, $event, $arguments){
        $focus->description = 'test';
    }
    
  • Update the bean instead

    $user= BeanFactory::getBean('users', '27283e5a-8f34-b846-367a-561fbbb4cb54');

    $user->description = 'Test';

Reply Children