Page 1 of 1

How can I reset a datetime field (set it to NULL)?

Posted: 15 May 2019
by DonCortizone
Hi,

I'm trying to set a DateTime field to null, when a user clicks on a checkbox:

Code: Select all

function onSomeBooleanFieldChange() {
    if (fd.field('someBooleanField').value() != true) {
        fd.field('someDateTimeField').value(new Date()); // works        
    } 
    else {
        fd.field('someDateTimeField').value(null); // does not work
    }
}
Setting a datetime field to null, leaves the values in the UI unchanged. And when saved, the original date value is saved and not the null value.

As a work-around I tried hiding the datetime control. This works, but there is still a datetime value saved instead of a null value.

How can I reset a datetime field (set it to NULL)? Any help is highly appreciated!

Re: How can I reset a datetime field (set it to NULL)?

Posted: 16 May 2019
by DonCortizone
I finally found it, you have to assign an empty string:

Code: Select all

fd.field('someDateTimeField').value('');