Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at firstname.lastname@example.org
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.
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
Also if you observe carefully, the date is actually greyed out. It’s actually more of like a placeholder value but nonetheless annoying.
- Business Rules in PowerApps Canvas apps
- How to set up Custom Url for PowerApps Portal/ Dynamics 365 Portal
- Reset a PowerApps Portal – A Complete Guide
- Error Management in PowerApps/ Dynamics 365 Portals – A complete guide
- Diagnostic logging in PowerApps portals/ Dynamics 365 Portals
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.
Once we do that, the next step is to select the date picker and set the DefaultDate property to the below formula.
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.
Simple and yet a requirement that pops up every now and then.
Hope this helps!
(Business Solutions MVP)