Can we default time to 00:00 for date field?
Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

Can we default time to 00:00 for date field?

Currently, it is not possible to set the default time to 00:00 for the date field using JSON. However, we can achieve this through a custom workflow.

Workaround (for versions before v11.x)

In OpenSpecimen versions before 11.x, you can utilize the following workaround:

Use "defCollectionDate": "none" and place it under the specimenCollection section.

This approach will:

  1. Leave the collection date empty.

  2. When the user selects a date, the time will automatically default to 00:00.

Please be aware that this workaround is no longer effective in version 11.0 and above.

Recommended Solution: Use Custom Workflow

To consistently set the time to 00:00, implement a custom workflow and configure it in the defaultValues function.

Example: This will set the collection date to today with the time defaulting to 00:00.

const collectionEvent = Object.assign({}, specimen.collectionEvent || {}); const today = new Date(); today.setHours(0, 0, 0, 0); // Set time to 00:00 collectionEvent.time = today.toISOString(); return [{ collectionEvent }];
Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com