Stupid Salesforce.com + Google.com Trick (or, Calendar + GMAIL + Email2Apex = hacky cron)

One of the things salesforce.com lacks is a decent analog to “cron”, the ubiquitous unix/linux job scheduling tool. This is a kludgey but mildly amusing solution. (Here’s a simple, less kludgey cron that’s all native SFDC, which is probably a better idea if it meets your needs).

In order to implement this version, you’ll need a Google account with access to GCal and GMAIL, and a SFDC developer account.

The basic idea is to use Google Calendar as a signal to SFDC that it’s time to run a process. The works because of the Calendar’s reminder feature. The Calendar fires off a reminder email to the linked GMAIL account. GMAIL forwards that to SFDC. SFDC receives the message and does something (represented below by calling a “delegate”).

Eh voila! You have a rough analog to cron. (BTW, you could do this with any calendar that sends a reminder — Yahoo, etc.)

The basic flow looks like this:

Stepwise deployment:

  1. Setup your SFDC developer account.
  2. Setup your Google account.
  3. In SFDC, create a delegate — an Apex class callable from the Messaging.InboundEmailHandler) that does whatever you want to have happen on a regular basis.
  4. In SFDC, configure an Email2Apex InboundMessage handler APEX class. Note that this handler has to match the interface, but it doesn’t actually need to do anything with the email itself.
  5. In SFDC, configure the Email Service and setup an email address to accept alerts.
  6. In GMAIL, go to settings and configure the forwarding option so it goes to the SFDC email address you configured above.
  7. In GCal, configure your system to sent automatic reminders via email. This is under Settings > Calendars > Notifications.
  8. In GCal, schedule a recurring event. Make sure the event it setup to send a reminder or that your default calendar settings send a reminder.

Email Services Picture:

Email Service Configuration (with email address):

Some pluses of this approach:

  1. Facilitates a variety of signal times. With the time based workflow and trigger method, you are pretty much stuck with a pretty steady schedule that only operates in a minimum of hour increments.
  2. Email2Apex Inbound Message handlers have a larger DML limit than triggers. (100 instead of 20).
  3. Pretty easy, no code or hosting required.
  4. Doesn’t consume a custom object.  (Yes, I have run into people who have run out of custom objects.)

Some minuses of this approach:

  1. Two systems. Two distinctly different systems. Management needs to be handled twice, people have to remember where the signal is coming from, etc.
  2. Email, although pretty darn good, is far from a perfectly reliable signal.

Possible Enhancements

  1. You could use the SFDC provided APEX Google Calendar API to create the recurring events. That would reduce the number of perceived systems involved. Say you wanted to create an SFDC custom object that stored cron style settings and then in the background it managed the details of configuring the recurring events. Actually, this sounds mildly amusing. If you develop this, I’ll gladly buy you a cup of decent coffee.
  2. If you have a number of items that need to be scheduled, you can actually use GMAIL filters based on the GCal subject line to either a) forward to different InboundMessageHandlers (if you need different schedules) or b) put a tree in the single handler that sends tasks off to different delegates.

(BTW, I haven’t looked to see if this idea is compliant with any of the players’ terms of service–at your own risk.)

Chicago at Night



Chicago at night, originally uploaded by ReidCarlberg.

Taken from Belmont Harbor.

Cool Chicago spot: fine arts b…

  • Cool Chicago spot: fine arts building, 410 s michigan, 4th floor, ste 433n ascend training has a courtyard. You can probably get in. Awesome #
  • Cool chicago spot: the restrooms at devon seafood grill. Chicago & wabash, lower level. Very nice!! #
  • still trying to arrange vacation housing. It’s getting closer. #
  • My metra lotto winnings have fallen this week. I might have to buy a new pass. BTW A coworker reported 22 rides on a 10 ride pass. VeryNice #

I can only assume TechCrunch is referring to me.

TechCrunch has a post this morning on Justin.TV’s 1 millionth user.  Having just signed up, I can only assume it was me that pushed them over the edge.

In fairness, it wasn’t that hard.  Nonetheless, I’d like to thank The Critter who poses in my “not broadcasting” photo.  I’d like to thank the City of Chicago for being so beautiful when I took my header photo last February.  And, most of all, I’d like to thank the little people, notably Herve Villachaize, who gave me the confidence that I too had something to offer the TV viewing public.

Thank you, thank you, thank you.

Oh: one last question: 109 years of archived video???  Really?  No seriously: Really?

@shobyabdi hey man can we talk…

  • @shobyabdi hey man can we talk some work stuff real fast before the movie starts? Somewhat urgent……………………………….JK #
  • @shobyabdi the work remark was much funnier when i sent it one minute after you said “no phone calls” cause of the dark knight. slow sms. #
  • trying to find a decent hotel in YORK, ME. Any ideas? #
  • Quality movie weekend continues. Mall Rats. Wedding Singer. Coyote Ugly. #

The only problem with being ma…

  • The only problem with being married to a vegetarian is that when I make a really good coq au vin for myself no one can vouch for its flavor. #
  • @popejephei i think i’ll give golf advice to non-golfers. strikes me as the safest course. #
  • Cooking! Vegetarian Risotto for tonight, cog au vin part deux for tomorrow night. I should open some wine for the drinking, too. #

@shobyabdi thanks! I’m prepari…

  • @shobyabdi thanks! I’m preparing a submission to Sundance. Should be fantastic. Don’t see any reason why it wouldn’t win. #
  • iDenial, Episode 3: http://tinyurl.com/6xzztb #
  • iDenial Live! http://tinyurl.com/5e5sty Share your story of life without an iPhone. #

That pesky question mark?

I was reading about the Large Hadron Collider and ran across this sentence:

He added: “Our motto is: no short cuts?

And thought — really?  Cause if you look at the whole paragraph:

He added: “Our motto is: no short cuts? exchanging a single component which today is cold, is like bringing it back from the Moon. It takes about three to four weeks to warm it up. Then it takes one or two weeks to exchange. Then it needs three to six weeks to cool down again.

It would seem that short cuts would be out of the question.  Which the question mark suggests is not the case.

Pesky punctuation.

Remember the first time you sa…

  • Remember the first time you saw the first Matrix? Hell yeah. #
  • i think i’ve turned into the worst kind of beginner golfer: the kind that likes to give advice to other beginning golfers. Blech. #
  • Mmmm eating a little sour patch kids extreme. Soooo tasty. On the flip side, union station is hot! And not in a paris hilton kinda way. #

iDenial, Episode 3: Friday