Since we review every add-on submission to SugarOutfitters we get to see some pretty cool implementations both on the user side and the code side. On the flip side, sometimes we see things that could cause significant conflicts and issues if installed. Recently one such common implementation has been popping up surrounding adding custom Scheduler Tasks. There is a legacy way of adding jobs that is still being used and that is by adding jobs directly to custom/modules/Schedulers/_AddJobsHere.php.

DO NOT DO THIS!

The _AddJobsHere.php file is a shared file meaning that other customizations can also directly use that file. So when you copy over that file any existing changes get blasted away. The safe way to add jobs is to use the Ext framework. Besides, it is really easy to do this. Just add the “schedulerdefs” array to your manifest:

Define the job/task in schedulerexample_job.php file:

Then define the label that will show in the Scheduler Job dropdown. The label will be your job named defined in $job_strings in upper case prepended by “LBL_”:

You could technically just copy your job to the Ext directory like:

And have your users run a “Quick Repair and Rebuild”, but...

This isn’t 2008 anymore!

It is time to step our game up and make things as absolutely easy as possible for users. Your users should never have to do any unnecessary additional steps after installing the module. By using the Ext framework in the manifest it automatically takes care of propagating the Scheduler Tasks. By the way, if you do need a “Quick Repair and Rebuild” to be done for some other reason use the post_install.php script and do it there instead. It’ll make it easier on the user and will save you support time as you can guarantee that the step has been done. We will cover how to do this in the next Dev Tip blog post.

With this emphasis on simplicity, lets take it to the next level and create the job for the user and auto-configure it.

What we have done so far is to simply add a custom scheduler task. It has not yet been scheduled to actually run. You could just document and instruct your users on how to go to Schedulers and create a new Scheduler. However, this step is one that is often incorrectly done and leads to a frustrating and bad overall experience. Instead, make it a part of your post_install.php script:

Do you have ideas on how to make this even simpler? On possibility is to warn the user upon install that the cron may not have been set up yet.

Like this post?

We'll send you an email once a month with the latest posts.

Subscribe to this blog

Random Spotlight
  • Callinize connects Sugar with your existing phone system in minutes. Click to dial, call popups showing CRM data, automatic call logging, and actionable analytics make selling easier by eliminating mundane tasks like call logging and dialing digits by hand. Callinize supports over 100 phone systems ...

    learn more
  • Save Your Team Countless Hours. SugarChimp syncs your lists in both directions so that you can work in your preferred application. Segment and Group your MailChimp subscribers based on SugarCRM data so you can market to the right people at the right time. Fully compatible with all versions and e...

    learn more
  • Know exactly what time it is for your clients BEFORE you call. See the current time on every Account, Lead and Contact record. Now you can call or schedule a meeting or send an email at just the right time.

    learn more
  • Show more addons

Keep up to date on the latest additions

We'll send you an email every month with handpicked add-ons, reviews, tricks and tips. Don't worry, we hate spam as much as you do.