Hey I am experimenting with JS onLoad to attempt to resolve an Issue I have.
The purpose is to set the Hour to 1am onLoad and onChange.
After I get this work I also plan to hide to the time but that is not included in this JS yet.
Here is the JS:
function updateHours(executionContext) {
//Get the context of the form
var formContext = executionContext.getFormContext();
// Access the field on the form
var StartFieldAttribute = formContext.getAttribute("test_startdate");
var EndFieldAttribute = formContext.getAttribute("test_enddate");
if(StartFieldAttribute.getValue()!= null)
{ var StartFieldValue = StartFieldAttribute.getValue();
var StartFieldValue = StartFieldValue.setHours(1, 0, 0);
StartFieldAttribute.setValue(StartFieldValue);
}
if(EndFieldAttribute.getValue()!= null)
{
var EndFieldValue = EndFieldAttribute.getValue();
var EndFieldValue = EndFieldValue.setHours(1, 0, 0);
EndFieldAttribute.setValue(EndFieldValue);
}
}
here is it in plain text:
function updateHours(executionContext) {
//Get the context of the form
var formContext = executionContext.getFormContext();
// Access the field on the form
var StartFieldAttribute = formContext.getAttribute("test_startdate");
var EndFieldAttribute = formContext.getAttribute("test_enddate");
if(StartFieldAttribute.getValue()!= null)
{ var StartFieldValue = StartFieldAttribute.getValue();
var StartFieldValue = StartFieldValue.setHours(1, 0, 0);
StartFieldAttribute.setValue(StartFieldValue);
}
if(EndFieldAttribute.getValue()!= null)
{
var EndFieldValue = EndFieldAttribute.getValue();
var EndFieldValue = EndFieldValue.setHours(1, 0, 0);
EndFieldAttribute.setValue(EndFieldValue);
}
}
Here is the error message:
Value should be of type: Date: Parameter Name: value
Event Name: onload
Function Name: updateHours
Any help is appreciated