Today I got requirement to open new record form with prepopulated DateTime field. This article describes how to pre-set Date field:
The following sample sets the Est. Close Date field for a new opportunity to January 31, 2011. The unencoded value for the extraqs parameter is “estimatedclosedate=01/31/11”.
No single word about time component. Luckily I found a way to make it work. Format that should be used is following – M/d/yyyy H:m:s, something like to 1/31/2011 15:6:0.
Here is the code snippet you can use to open new task for prepopulating Due Date field with the same time as now plus 1 day:
var tomorrow = new Date(); tomorrow.setDate(tomorrow.getDate() + 1); var formattedTomorrow = (tomorrow.getMonth() + 1) + "/" + tomorrow.getDate() + "/" + tomorrow.getFullYear() + " " + tomorrow.getHours() + ":" + tomorrow.getMinutes() + ":" + tomorrow.getSeconds(); var entityFormOptions = { entityName: "task" }; var formParameters = { scheduledend: formattedTomorrow }; Xrm.Navigation.openForm(entityFormOptions, formParameters);