Skip to main content

Posts

Showing posts from July, 2011

CRM 2011 Holiday Retrieval

Holidays in CRM are stored in the CalendarRules entity but unfortunately Retrieve and RetrieveMultiple messages are not supported for this entity.  Below is a snippet of code that will help to find the CalendarId that contains the holidays and how to retrieve the individual holidays themselves.

           var org = (from o in Context.OrganizationSet
                          select o).FirstOrDefault();

            var businessClosureCalendarId = org.BusinessClosureCalendarId.Value;
            var businessClosureCalendar = (from c in Context.CalendarSet
                                           where c.CalendarId == businessClosureCalendarId
                                           select c).FirstOrDefault();

            var calendarRules = businessClosureCalendar.CalendarRules;

Enjoy!