Nuxeo Server

How to Set a Default Date on a Field at Document Creation

This page is scheduled for review and update. Check back soon for updated content!

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.

2 months ago Loubna Benzaama Fix Showcase Content add-on doc
3 years ago Manon Lumeau 13
3 years ago Manon Lumeau 12 | Fix images
3 years ago Manon Lumeau 11 | Fix Studio menu label
3 years ago Solen Guitter 10
4 years ago Solen Guitter 9
4 years ago Manon Lumeau 8
4 years ago Manon Lumeau 7
4 years ago Manon Lumeau 6
5 years ago Solen Guitter 5
5 years ago Solen Guitter 4 | Added excerpt
5 years ago Solen Guitter 3
5 years ago Bertrand Chauvin 2
5 years ago Bertrand Chauvin 1
History: Created by Bertrand Chauvin

We'd love to hear your thoughts!

All fields required