Wednesday, April 1, 2009

Recurring Appointments

Anyone who has been using CRM for a while knows that there is no support (at this time) for recurring appointments. However, with the fantastic workflow engine in v4.0, it is possible to simulate the functionality of a recurring appointment, without actually creating them in the same fashion as Outlook allows.

The first step in creating this functionality is to create a couple of extra fields on the appointment - one to specify the recur timeframe, and one to hold a date value. The recurrence field in my case was a picklist of yearly, quarterly, monthly, weekly. When set, this triggers the workflow. The date value will help us later in preventing a runaway workflow process.

Now we can create our workflow. For my sample, I triggered the workflow when the appointment was created, and checked for a value in the recurrence field - if nothing is there I know this is not a recurring appointment and the workflow stops. Next, I checked my date field. The purpose of this field is to hold the date (and time) of the original appointment record - the one that is triggering the recurring appointment. Because I don't want this workflow to enter an endless loop, I wanted to wait for the date of the originating appointment to pass before I create my next appointment in the future. This prevents each subsequent appointment from triggering its own workflow and continuing ad infinitum.
So my next step is to see if my custom date field contains any data. If it does not, I know this is the first appointment in the series, and I can create the next in the series and stop. If it does, then I need to wait for that date to pass before creating the next in the series.

Finally we get to the obvious part - for each value in my recurrence picklist, I simply have to specify the criteria for creating the next appointment. For example, if this field is set to "weekly" then I need to add 7 days to the appointment date fields when creating the new appointment. I also have to remember to set the original appointment date into my custom date field for use above. Everything else I copied over directly.

The end result is that I now have a rolling cycle of 2 appointments in my series. The next to occur has already completed its workflow (it created #2 in the future) , while the second in the series is waiting for the date of the first one to pass before it creates the next in the series and stops, and so on. As each appointment passes, the second in the series becomes the next, and it creates its own successor to repeat the process.

This workflow functions pretty well, but there are of course some limitations. If you need to make a change to the appointment, you have to make sure to change the second in the series, or that change won't get copied into any new appointments. You are also limited to only these two appointments in the series - if you have a weekly recurring appointment you will only see the next two weeks. Checking your calendar 2 months in advance won't show the appointment at all. You also have to set the recurrence field from the CRM appointment window and on a new appointment for anything you already have set up in Outlook (the Outlook client will not allow recurring appointments to be tracked at all). Limitations aside, however, this is a pretty decent workaround.

Enjoy!

No comments:

Post a Comment