Blog
SharePoint - How to clear datetime fields/set an empty datetime value on a form
July 21. 2021
A problem that some app builders encounter is that on edit forms, clearing the value of a datetime field doesn't work. This post describes this issue in more detail.
A very common requirement is to build data entry forms with non-mandatory datetime fields. Let's take the example of an edit form that's based on a SharePoint list of issues. This list includes an optional field called 'target close date'.
At runtime, the user edits an existing record with a 'target close date' and attempts to clear this by deleting the existing value in the date control.
When the user saves the record, Power Apps does not correctly clear the value and does not display any error messages. When the user subsequently opens the record, the old 'target close date' value still appears.
How to enable the ability to save null/empty datetime values
The simple and quick fix to this problem is to enable the "Formula-level error management" option in the settings of the app. It's necessary to reload the app for this setting to take effect.
With this setting enabled, the app will behave as expected, and users can correctly clear, or set datetime values to blank/null by clearing the value in the date picker control.
As a point of reference, the 'Formula-level error management' option is the setting that enables the ability to save null values. It's also the setting we would apply when we want to set a SQL Server field value to null by patching a Blank() value (which is another common issue that app builders encounter).
Conclusion
If you're unable to set a datetime value to blank or null, the fix to this problem is to enable the 'Formula-level error management' option in the settings of an app.
- Categories:
- forms
Related posts
- Forms - How to set the value of a field to todays date for new records only
- Apps - How to create an app from a hand drawn image
- Forms - How to highlight user modified field values on a form
- Forms - How to append text to field in a data source
- Forms - How to calculate values (eg sums and products) and store the results in SharePoint or other datasource
- SharePoint - How to programmatically set and clear single select choice items in a combo box on a form
- Forms - How to convert a display form to an edit form
- Forms - How to copy/save an existing record on a form as a new record
- Forms - How to show Office 365 user profile details on a form
- Forms - How to hide fields that are blank, or have not been completed
- Forms - How to select-all / unselect-all checkbox or toggle controls on a form
- Forms - How to set the data source of a form to a collection
- Forms - The best practice for setting the data item on a form
- Controls - How to set default control and form values
- Forms - How to conditionally make form fields mandatory