Among many challenges of working with Model-driven app and Common Data Service, one specific that took some time to figure out was how to clear a Date Field in CDS.
While trying to figure this out, I used various methods (that did not work for me btw but might work in your situation). These are :
- Assign a new blank date Field to the existing CDS field.
- Assign Blank() to the CDS Field.
- Assigning bank text to the Date field.
What actually worked for me at the end was the conventional Dynamics Process that would run to clear the Date Completed field when a certain condition is met.
In my case, the Date Filed was called “Date Completed” and a check to clear it was a two options field called “IsComplete”. Setting IsComplete to yes (through my canvas-app) would trigger the process below and clear the Date Filed in CDS record.
Corn – Because the process works asynchronously, there is a delay in clearing the field value in CDS.
Steps to configure are –
- Create a new Process workflow in Power Apps from within your solution or from dynamics classic window under your entity.
- Set the parameters as below for Scope, Record Field Changes, automatically delete completed workflow jobs, and Run this workflow in the background.
- Add a new Step with Condition on your Indicator field. For example, IsComplete equals to No as in my case.
- Add Update Item step.
5. Select the Date Field to clear and then set the clear operator.
6. Save and activate the proccess.
In my case, I am patching the IsComplete value from my embedded Canvas-app but you can also update it through flow (manually triggering flow from within the model-driven app) which in turn will trigger the process.
Hope it helps!