I am on Laserfiche Forms Professional Version 12.0.2509.20409 using the modern designer and when I try to set a time field value through JavaScript, it looks good on the form, but when it is submitted, I get the below error:
Errors encountered during forms submission: Field Name: Time, Position: 0, Error: This value does not have a proper time format. [LFF9305-InvalidTimeFormat] [LFF9312-ErrorOccuredDuringFormsValidation] [LFF9320-FormsValidationAggregateException]
For troubleshooting, I have a form with only a time field. I then have the following JavaScript:
function logTime(){
console.log('Starting Log');
let timeVal = LFForm.getFieldValues({fieldId: 1});
console.log("timeVal: " + timeVal);
const timeJSON = JSON.stringify(timeVal);
console.log("timeJSON: " + timeJSON);
console.log('Ending Log');
}
console.log('Starting Form');
LFForm.setFieldValues({ fieldId: 1 }, {timeStr: '7:44:46 AM', dateTimeObj:'2026-01-06T12:44:46.000Z'});
LFForm.onFieldChange(() => logTime(), {fieldId: 1});
console.log('Ending Form');
I know that the documentation says that a time field only takes a timestr value/property and I have tried to set it with and without the dateTimeObj value/property and get the same thing. If I manually set the time value through the form, then it submits without error.
I have found that when I get the field value after the field has changed, it includes the dateTimeObj value/property in the returned object. I then found that the dateTimeObj value/property is different when set though code than when it is set manually through the field on the form. Below is from the DevTools console and it shows both when the field was set through code and then again when I manually changed it. Notice that when I set it with code, the date is 1/1/2000, but when I set it through the field, the date is 1/1 of current year.