Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Min Date allowed in CRM is 01/01/1753 00:00:00, however fake xrm easy allows 01/01/0001 00:00:00 #562

Open
dikshitdhawan87 opened this issue Jun 2, 2021 · 2 comments

Comments

@dikshitdhawan87
Copy link

dikshitdhawan87 commented Jun 2, 2021

Bug Description
If you try to create a record in CRM where a DateTime Field's value is set to any date < 01/01/1753 00:00:00
Then CRM throws an error -
Microsoft.Xrm.Sdk.Entity Exception Details: DateTime is less than minimum value supported by CrmDateTime.
Actual value: {value provided}, Minimum value supported: 01/01/1753 00:00:00

Fake Xrm Easy should behave the same way so that we can write units tests around the functionality.
Currently Fake Xrm Easy does not throw any exception if the provided DateTime Value is less than "01/01/1753 00:00:00"
and works fine(i.e. creates the record) => hence not mimicking the actual behavior of CRM

To Reproduce
//C# Code

        private static CrmServiceClient _service;
        string url = "**********************";  // e.g. https://yourorg.crm.dynamics.com
        string userName = "*****************";  // e.g. you@yourorg.onmicrosoft.com
        string password = "********";          // e.g. y0urp455w0rd 
                 
        string conn = $@"
            Url = {url};
            AuthType = OAuth;
            UserName = {userName};
            Password = {password};
            LoginPrompt=Auto;
            RequireNewInstance = True";

        _service = new CrmServiceClient(conn);
        var contactToBeCreated = new Entity("contact");
        contactToBeCreated["birthdate"] = DateTime.MinValue;
        try
        {
            var recordId = _service.Create(contactToBeCreated);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

Expected behavior
An exception should be thrown
"Date is less than the minumum value supported by CrmDateTime. Actual value: 01/01/0001 00:00:00, Minimum value supported: 01/01/1753 00:00:00"

** FakeXrmEasy and Dynamics 365 / CRM version **
FakeItEasy | version="6.0.0"
FakeXrmEasy.9 | version="1.57.1"

D365 - V9.2

@jordimontana82
Copy link
Owner

Thanks for reporting this. Did you have a chance to try if this happens in earlier versions of CRM as well?

@dikshitdhawan87
Copy link
Author

dikshitdhawan87 commented Jun 2, 2021 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants