NLP Date Picker

Date field is notorious for slowing the user down during form entry because this is where the user tends to make mistakes with incorrect formats, typos, calculating the dates off the top of the head considering some months have 31st and some don’t, let alone the leap year calculations.

So, how can we improve this? It turns out we already have tamed this in our day to day colloquial languages. We mostly do not use the specific dates, but use yesterday, in 5 days, 10 days ago, 13th October etc., What if we bring the same idea to the Dynamics 365 form?

With PCF, this is no more just a dream. We can dramatically simplify this.

Here is a quick demo:

Out of the box Dynamics 365’s date type field uses the Office UI Fabric’s datepicker. As we have access to Office UI Fabric’s api, we can enhance the Date control and embed it as a PCF control in the Dynamics 365 form.

It turns out Natraj Yegnaram already has a PCF control that leverages Office UI Fabric’s datepicker that I had to enhance to parse the natural language entry.

Office UI Fabric’s DatePicker has many options to customize the datepicker. I had to leverage some of these options to enable the text entry and custom date parsing on the date picker so as to allow the date entry in the natural language. This control uses Sugarjs date api in order to parse the natural language entry to an appropriate date to store in the D365.

Go ahead and try it for yourself. This is by far the most simpler and fun way to type the dates in.

Some sample entries include:

  • 22 November
  • today
  • last year
  • 15th
  • five years ago
  • next Saturday
  • two days after tomorrow
  • the beginning of this month
  • two weeks from today
  • . . .

Full source code is available on github.

Have fun!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s