Addons

HOWTO: Set a Default Date on a Field at Document Creation - JSF UI

Updated: October 10, 2024

JSF UI Deprecation
This requires to have the JSF UI addon installed on your server that is deprecated since Nuxeo Platform LTS 2019.
Please refer to the Web UI documentation.

A frequent requirement with documents is to set a default date on a field when showing the creation form. This how-to will teach you how to do it easily using Nuxeo Studio's event handlers and automation chains.

Before You Start

Make sure that the Nuxeo JSF UI target package is checked in your project's Application Definition to get all the needed features in Nuxeo Studio.

Creating the Event Handler

In Nuxeo Studio, go to Automation > Event Handlers and add a new event handler. Name it and click Next.

In the Event Handler Definition section, make sure to select the event "Empty document created". This event will be fired right before the document form creation is shown to the user.

In the Event Handler Activation section, you may add filters to define conditions for your event handler to be used. You may relate it to a certain document type for instance, especially if you need to fill a document type specific field.

Creating the Associated Automation Chain

Now that you have setup when the event handler will take place, it is important to tell what it will do. To do so, in the Event Handler Execution section click on the button Create. Note that you may also use an existing automation chain if you created it previously.

Name your chain and click on OK.

In the automation chain, use the following operations and parameters:

Operation Parameter Value
Fetch > Context document(s)    
Document > Update property Value @{CurrentDate.calendar}
  Xpath schema:field

And that's it! Note that the previous parameter will set today's date, but you may use Nuxeo Studio's expression builder to change it. Many possibilities exist in that regard.