Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Calculating trigger date time with TimeTrackingCalculation.CalculateTriggerDateTime method

Posted on by 185

Hello.

I am working with Microsoft Dynamics CRM 2016 On Premise (8.0.1.79). One of important business tasks in my project is to calculate estimated date and time based on starting date, specific term in minutes, service calendar and holiday schedule.
This process executes in a plugin that fires on create of an entity. From the article below I learned about the public TimeTrackingCalculation.CalculateTriggerDateTime method in the Microsoft.Crm.Service.ObjectModel assembly. This method solves the task.

https://community.dynamics.com/crm/b/bettercrm/archive/2017/08/02/list-of-undocumented-sdk-messages

I pass ID of service calendar as calendarId, starting date as startDate, term in munites as triggerDuration and execution context of a plugin. This approach works perfect in most cases, but sometimes the result of the message is unexpected.
For example, I have an incident created at 20.12.2017 11:11. This incident should be processed in 5940 minutes (or 11 days) by an operator who work from 9:00 AM to 18:00 PM (9 hour or 540 minutes) in all days except Saturday and Sunday.
Holiday schedule related to a service calendar for this operator includes russian New Year holidays (1.01.2018 - 8.01.2018).
I guess the result of CalculateTriggerDateTime with this parameters should return 12.01.2018 11:11 (20.12.2017 plus 11 business days of term plus 9 days of holidays) but it always returns 11.01.2018 18:00, two hours and 11 minutes are lost.
The same glitch is observed for some other terms when there are holidays between start date and "trigger" date.

I realize that this SDK message is undocumented and MS cannot guarantee the result, but this solution is brillrant for us due to its simplicity. Maybe, this is a known problem and there's a way to predict wrong result and correct it?
Or this is the totally bad idea and we should redesign our solution according to documented functionality?

*This post is locked for comments

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Calculating trigger date time with TimeTrackingCalculation.CalculateTriggerDateTime method

    Hi,

    "MS cannot guarantee the result" - This is one of the main reason of only using the documented feature. As you mentioned, it is possible that its a know issue and thats why it is not a documented method to use.

    I would suggest to redesign using the supported method.

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,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans