AnsweredAssumed Answered

Why does the job fail when calling save() on a record?

Question asked by Asaf Army on Dec 2, 2014
Latest reply on Dec 3, 2014 by Esteban Schmirman
i created a scheduler job and when i call save() on a User module record and expect the User before_save logic hook to be called, the job fails.
no error in sugarcrm log except "failed in CRON" and no error in the apache log.
The code never gets to the user before_save logic hook so the problen is not there....
what seems to be the problem?

this is the code:


//add the job key to the list of job strings
array_push($job_strings, 'gc_notif_refresh');

function gc_notif_refresh()
{

  $userBean = BeanFactory::getBean('Users');
  $users = $userBean->get_full_list();
  if ( $users == null ) 
  {
   $GLOBALS['log']->fatal("No Users Found!");
  }
  else
  {
   foreach ($users as $user) 
      {
       if ( $user->status == "Active" && $user->gc_enabled_c == 1)
       {
       
       
        $user->save();  // FAILS!!!!
       
       }
      }
  }
 
  
  //return true for completed
  return true;
}
?>


using community edition 6.5.13

Outcomes