AnsweredAssumed Answered

Setting time portion of date time control

Question asked by sjnbham on Mar 3, 2015
Latest reply on Mar 15, 2016 by chenomenon

We're trying to set the default hour and minute values for some date/time controls on a Nintex form. We don't want to set the date portion of the control or we'd just use the SharePoint column default value option or the JavaScript variable option in the Nintex form settings.

 

Temporary Workaround
Use the correct ID sets for the mode the form is in. The IDs can be different for the same field when the form is in New/Edit/Display. Thanks to Chit and this post for the idea about testing form mode: How can I get the form mode (New, Edit, Display) using jquery (NFW$)?

 

var isNewMode = document.location.pathname.indexOf("/NewForm.aspx") > -1; var isEditMode = document.location.pathname.indexOf("/EditForm.aspx") > -1;  if (isNewMode) {   /*set time values*/ var PreTrialHour = 1 + " " + "PM"; var PreTrialMinute ="30";  /*populate the time fields*/                        document.getElementById('ctl00_ctl43_g_55233958_e3e3_4fc0_8fd8_8cf8652d8648_ctl00_ListForm2_formFiller_FormView_ctl86_DateHours').value=PreTrialHour;   document.getElementById('ctl00_ctl43_g_55233958_e3e3_4fc0_8fd8_8cf8652d8648_ctl00_ListForm2_formFiller_FormView_ctl86_DateMinutes').value=PreTrialMinute;    }  if (isEditMode) {   /*set time values*/ var PreTrialHour = 1 + " " + "PM"; var PreTrialMinute ="30";  /*populate the time fields*/                        document.getElementById('ctl00_ctl43_g_4c336315_ff71_484c_844e_96f33d3e5580_ctl00_ListForm2_formFiller_FormView_ctl86_DateHours').value=PreTrialHour;   document.getElementById('ctl00_ctl43_g_4c336315_ff71_484c_844e_96f33d3e5580_ctl00_ListForm2_formFiller_FormView_ctl86_DateMinutes').value=PreTrialMinute;   }

 

 

Anyone have a better way to set the hour and minute fields that doesn't rely on the ID value of the individual fields which can change over time?

Outcomes