web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

Customer Service calendar Dynamic 365

(0) ShareShare
ReportReport
Posted on by 407

Hello,

I have a Business requirement whenever case is created, I have to check the created case time that is between business working hours so i can route to proper queue.

I need to do it with code activity (custom workflow). I am able to get the type 2 calendar ( customer service calendar type) but i not able to find the start time and end time of business hrs.

QueryExpression query = new QueryExpression(Constants.CALENDAR_ENTITY);
query.ColumnSet = new ColumnSet(true);
ConditionExpression condition = new ConditionExpression();
condition.AttributeName = "type";
condition.Operator = ConditionOperator.Equal;
condition.Values.Add(1);
query.Criteria.Conditions.Add(condition);
EntityCollection calendars = service.RetrieveMultiple(query);
EntityCollection calendarrule = calendars[0].GetAttributeValue("calendarrules");
var innerCalendarId  = calendarrule[0].GetAttributeValue("innercalendarid").Id;
var innerCalendar = service.Retrieve("calendar", innerCalendarId, new ColumnSet(true));
var innnerCalendarRule = innerCalendar.GetAttributeValue("calendarrules").Entities.FirstOrDefault(); 

In the code i am getting the innercalendar and also offset & Duration. But how do i check the if it is between business hours. I don't see any start/end time though it is define when we created Type 2 calendar.

4704351.Capture.PNG

Suggest me only the via code only how can solve this.

Thanks in advance!! 

I have the same question (0)
  • AM-22040756-1 Profile Picture
    407 on at

    Temporary , I found to add this in my existing code.

    TimeSpan workinhHrs = TimeSpan.FromMinutes(Convert.ToDouble(innnerCalendarRule["duration"]));
    TimeSpan startTime = TimeSpan.FromMinutes(Convert.ToDouble(innnerCalendarRule["offset"]));
    TimeSpan endTime = TimeSpan.FromMinutes(Convert.ToDouble(innnerCalendarRule["duration"])   Convert.ToDouble(innnerCalendarRule["offset"]));
    
    startOfDay = DateTime.Today.Add(startTime);
    endOfDay = DateTime.Today.Add(endTime);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans