How to initialize a Date field with Now?

Hello,
I would like to initialize a Date field with Now but using the initial value “Now” in the Form Model seems not permitted:
image
Is there a way to achieve this?
Thanks and best regards

Hi @jakob-atomic-haze ,

You can’t add a string initial value to a Date type (as it shown on the error it should be a date in a specific format).

I don’t think that is achievable by modeling, but I would say it’s possible by customizing the TextLineStateless on the WidgetMap (after checking for the field id) and rendering the current date.

Modifying the rendering could be a bit misleading as it would only influence the value shown in the UI but not store the initial value in the document.

We have also faced this issue multiple times now. In this case, the only solution we found is to do the initialisation in code in a saga/middleware. You could mark the fields that should be initialised with an annotation, then pick them out and fill them in the saga (after waiting for the document to be ready using waitForStateChange → documentLoaded).

I think it would be nice to have this as an A12 core feature since this seems like a common requirement. I have proposed initialising with expressions in A12-13865 (which is in review), I see there are also other tickets related to this requirement.

Thanks for your support. I think it would be really nice to have this as a standard modelling feature.