Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Unanswered

Customer Service calendar Dynamic 365

Posted on by 405

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!! 

  • AM-22040756-1 Profile Picture
    AM-22040756-1 405 on at
    RE: Customer Service calendar Dynamic 365

    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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans