Well, this one is indeed weird when I first time saw it. So basically we set up custom datetime format in portals to dd-MMM-yyyy.
If you are unware of custom datetime format in portals, you can follow this blog here.
All set and done, I launch a webform and the first step of the webform is the account details page. I have field “New Date Field” on the form. Remember the format of datetime in portal is dd-MMM-yyyy.
In line with the format, I try to key in the date – 12-Oct-2020. And observe the behavior.
As you can see from the above experience, the moment in keyed in “t”, it printed the new date. Trust me this is one of the hardest bugs to catch and if I would not have faced this one, I could never know about it.
What is our way out here? Well, I am a developer by heart and whenever something like this comes up, I try to dig in to the root cause of it.
The first thing I wanted to check if there is any keydown handlers attached when I press the key ‘t’. To find that, I tried the below code
Here “cr6d3_newdatefield” is my date field logical name in CRM. So you can see there is a keydown event handler and using the developer tools I went inside that function
As you can see from the below screenshot, there is a function attached on keydown of character ‘t’ which sets the value to current datetime.
Awesome isn’t it, to find these little little things. So exploration is done. Now what is the next step? How to make it work.
Well the easiest option I found was to remove the keydown event altogether.
$(“#<yourdatefield>_datepicker_description”).data(“events”)[“keydown”].handler = null;
Well, not the most elegant but certainly it works.
Hope this helps!
Our product offerings:
CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)
Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)
Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)