Set Date Picker in Canvas App to today's date by default

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

This one will be real quick. A small and effective one I should say. But before we go into the solution, let’s understand the problem statement here.

My customer have a canvas app built on Common Data service (CDS). The canvas app has an edit form for the contact entity. There is a date field on the Contact form.

Canvas app set default date for date picker.

You might have already noticed the issue here. This is the edit form for contact record. The date field is set to default value – 12/31/2001, if the field is empty. A close look at the DefaultDate property of the Date picker field reveal it is set to Parent.Default

Canvas app set default date for date picker.

Also if you observe carefully, the date is actually greyed out. It’s actually more of like a placeholder value but nonetheless annoying.

Recent Posts

In this blog, we are going to set the default date, in case the date field is empty, to today’s date. Let’s tackle these scenarios one by one. The first thing is to go ahead, select the data card for the date field and Unlock the data card to change it’s properties.

Canvas app set default date for date picker.

Once we do that, the next step is to select the date picker and set the DefaultDate property to the below formula.

Canvas app set default date for date picker.

Formula Text

If(IsBlank('Date field'), Today())

I set the field to Today’s date using Today() function if the field is blank. The below screenshot show the formula in action.

Canvas app set default date for date picker.

Simple and yet a requirement that pops up every now and then.

Hope this helps!

Debajit Dutta
(Business Solutions MVP)


Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe to get the latest posts sent to your email.

Discover more from Debajit's Power Apps & Dynamics 365 Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading