If you have lots of users which need their work hours added into CRM, it can take a long time to manually set up each user through the user interface.

Below is the code to update user’s work hours in bulk for a regular 9am-5pm schedule and will also reflect on the Universal Resource Scheduling board.

 

 

This code works in 2 steps:

  1. I created a Fetch to retrieve all users which have a Bookable Resource.
  2. I run a for each loop through each user and pass that UserId into two methods:

This method clears the current Calendar of the users.

This method adds the Calendar rule specified for the users.

 

Important parts of the code that needs expanding:

You need to specify the ‘type’ attribute as -1 because this will then reflect on the Schedule Board. Here is a link for more information https://msdn.microsoft.com/en-us/library/dn689038.aspx

 

This pattern string specifies a schedule frequency for Monday to Friday. You can see more examples of different patterns here https://www.syncfusion.com/kb/3719/what-is-recurrencerule-in-the-schedule-control

 

Hopefully this post helps 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *