Custom scheduler job help needed

Discussion created by on Feb 28, 2017
Latest reply on Mar 7, 2017 by Francesca Shiekh


I have created a custom scheduler Job using a blog I found and have adapted it slightly as it was using get_full_list, to update calculated fields nightly without affecting modified dates the code is as follows:



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

function custom_job()
//custom job code
$bean = BeanFactory::getBean('Cases');
$SugarQuery = new SugarQuery();
$sugarQuery->from($bean,array('team_security' => false));
$result = $sugarQuery->execute();

if( $result != null ) {
foreach($result as $b) {
// These lines prevent the modified date and user from being changed.
$b->update_date_modified = false;
$b->update_modified_by = false;
$b->tracker_visibility = false;
$b->in_workflow = true;
print "Finished updating: $cnt records.\n<br>";

//return true for completed
return true;


However, I am getting an error in the Sugar logs:

Tue Feb 28 09:51:58 2017 [5115][1][FATAL] [SessionLock] Session lock was held for 5 seconds which is longer than the maximum of 1 seconds. Request details: SERVER_NAME: ...., SERVER_ADDR: Not set, SCRIPT_FILENAME: /mnt/sugar/, REQUEST_METHOD: Not set, SCRIPT_NAME: /mnt/sugar/, REQUEST_URI: , QUERY_STRING: Not set Tue Feb 28 09:51:59 2017 [5115][1][FATAL] Job 87bc8bea-fd9b-11e6-8219-062520151959 (Test Custom Job) failed in CRON run

We are on Sugar Enterprise Edition (Ondemand - The latest version), does anyone have any ideas where I have gone wrong, I apologise in advance, my development knowledge is limited.


Thanks in advance for any assistance, its greatly appreciated!