SugarCRM custom scheduler job.

Guys, today I am sharing how to create a installation package for custom scheduler job in SugarCRM.

For SugarCRM administrator, the scheduler job functions are always not enough for suit the business logic.
As a administrator, we are always need to create our customize job in order to fulfill the requirement.

In older version of SugarCRM (like 4.x), it required to modified the core file in SugarCRM to just add in a custom scheduler job function. As SugarCRM release version 5.X, it allow administrator add in a job without modifying the core file.

Here is an example on how to create a single scheduler job in SugarCRM 5.X.X.

1. Create a file and name it as “_AddJobsHere.php”

<?php
//SET THE job_string number to 3 digits to prevent crashing with sugarcrm pre-define job id.
$job_strings[102] = 'send_reminder';
 
function send_reminder(){
    //scripts
}
?>

2. Language file for Schedulers module.

<?php
//MAKE SURE THE KEY IS COMBINE OF "LBL_" & SCHEDULER JOB FUNCTION NAME
$mod_strings['LBL_SEND_REMINDER'] = 'Send Reminder';
?>

3. Prepare your package manifest.

<?php
    $manifest = array (
         'acceptable_sugar_versions' =>
          array (
			'5.x.x'
          ),
          'acceptable_sugar_flavors' =>
          array(
            'ENT','PRO'
          ),
          'readme'=>'',
          'key'=>'xxx',
          'author' => 'xxx',
          'description' => 'scheduler job package',
          'icon' => '',
          'is_uninstallable' => true,
          'name' => 'xxx',
          'published_date' => '2010-04-28 11:56:00',
          'type' => 'module',
          'version' => '1.0.0',
          'remove_tables' => 'prompt',
          );
$installdefs = array (
  'id' => 'xxx',
  'beans' =>
  array (
 
  ),
  'layoutdefs' =>
  array (
  ),
  'relationships' =>
  array (
  ),
  'copy' =>
  array (
    array (
      'from' => '<basepath>/SugarModules/custom/modules/Schedulers/_AddJobsHere.php',
      'to' => 'custom/modules/Schedulers/_AddJobsHere.php',
    ),
  ),
  'language' =>
  array (
    array (
      'from' => '<basepath>/SugarModules/language/Schedulers/custom.lang.php',
      'to_module' => 'Schedulers',
      'language' => 'en_us',
    ),
  ),
);

4. zip it and ready to install in your development.

5. Scheduler the job in admin > Scheduler





sample of installation package.

One Comment to “SugarCRM custom scheduler job.”

  1. […] Re: automatic creation of a record Originally Posted by garciasanchezdaniel hello! I created one field in edit view of my module Tasks. This field is a number, and this field mains the days when another task will be created automatically. For example, if I create one task right now, and in this field, I put one one week, next week will be created another task automatically. And in two weeks another task…and in three weeks another….this is periodically This is what I need implement, I read in internet that is possible through a script…but I'm lost right now… I hope your suggestions. Thanks in advance, Daniel I think a custom scheduler job will do the trick for you. Here a tutorial I found useful when i created my first custom scheduler jobs: SugarCRM custom scheduler job. | How 2 Guru […]


Leave a Reply to automatic creation of a record