We recently ran into a customer requirement for the ability to schedule weekly recurring service activities in Dynamics CRM 4.0. We realized that this new functionality could be quite useful for companies that schedule regularly recurring activities with their customers. A range of businesses from physical therapy to facility maintenance might be able to take advantage of such a feature.
The solution that we delivered used JavaScript built into the Service Activity entity form, that will determine if a given Service Activity is to be repeated and for how long. It will then call web services to create the resulting Activities. For those interested, here are the steps required to implement this feature.
Create Custom Attributes
Two customer attributes were created to determine if a Service Activity should be repeated and for how long:
-
new_recurringactivity – bit attribute type
-
new_recurringenddate – datetime attribute type
We then added these two fields to the Service Activity form as shown.
Add Form-based JavaScript
Next two pieces of JavaScript were created and loaded onto the Service Activity form.
The first, which is triggered off the OnSave event, checks to see if the current activity has been marked as recurring and also saves the end date of the recurring services. The script then calls the CRM web service to create multiple Activities with the same parameters as the original.
The second piece of JavaScript, that runs OnLoad, checks to see if the Service Activity is already part of a recurring series, and if so, disables the recurring detail controls.
Anyone interested in the actual JavaScript code can download the file from this link.


#1 by Cwb on October 13, 2009 - 12:38 pm
I have a couple questions. How do I go about adding the code to CRM. Do I need to export the service activity customizations .xml add the code and import it back in? Or am I going down the wrong path here?
#2 by Cory Fellers on October 13, 2009 - 1:02 pm
Javascript code such as this can be applied to entities in CRM using the customization interface. From your homepage navigate to Settings -> Customization -> Customize Entities -> Service Activity -> Forms and Views -> Form. From there open the Form Properties window. Inside the javascript file I provided are two segments of code. One of them should be inserted into the OnLoad event of the form and the other into the OnSave event of the form.
Let me know if you run into any trouble.
#3 by Kyriacos Kyriacou on December 13, 2009 - 10:55 am
Hi ,
I have tried to add this js to crm 4 in order to have recurring service activities but is just not working , it shows me errors on both load and save of a service activity …
Any advise ?
#4 by Cory Fellers on December 16, 2009 - 11:17 am
First verify that you created the custom attributes with the exact same names as those referenced in the javascript.
If that is not the issue, let me know what errors it is firing on the OnLoad and OnSave.
#5 by Deniz on December 18, 2009 - 3:48 am
Dear Cory, great contribution, thanks a lot.
#6 by PhilP on November 3, 2010 - 4:32 pm
Cory – the link to the js is no longer valid. Is it possible to still obtain the code?
#7 by Jawad on November 16, 2010 - 9:05 pm
Great work Cory,
After going through posts like these i was wondering if we can use workflows in CRM4.0 to create recurring activities.
I have managed to get them working for me in Microsoft Dynamics CRM4.0
You can go though these on the following link:
http://jawadarif.wordpress.com/2010/11/11/ms-dynamics-crm-4-recursive-service-activity/
I hope this would provide a different flavor and flexibility to the audiences.
Regards,
jawad