board logo
Posted by: WUICTeam - Sunday, November 15, 2026 3:25:16 PM
[b]Question[/b] I have a date column [c]data_inizio[/c] with a [c]mc_selection_changed_custom_function[/c] that computes [c]data_fine[/c] from the new value (fourth argument), as shown in the lookup/field widget docs: [code] (record, field, metaInfo, newValue) => record.data_fine.next(addDays(new Date(newValue), 30)) [/code] Every time I open an existing record in edit mode, [c]data_fine[/c] is overwritten with an invalid date, even when [c]data_inizio[/c] is empty. Logging [c]newValue[/c] shows a [c]BehaviorSubject[/c] object instead of the date. The same happens with multi-line text (textarea) columns. Numeric and text columns work fine. [b]Answer[/b] Confirmed bug, fixed in 1.8.2. When the form opened, the date and textarea editors read the record field itself (the [c]BehaviorSubject[/c]) instead of its current value. As a result: [list] [*]the function was called on form open even when the field was empty, because the subject is always truthy; [*]the fourth argument ([c]newValue[/c]) was the [c]BehaviorSubject[/c], so [c]new Date(newValue)[/c] gave Invalid Date; [*]on the first user edit the fifth argument (old value) was the [c]BehaviorSubject[/c] too. [/list] From 1.8.2 these editors behave like the numeric and text ones: on form open the function runs only if the field has a value and receives the real value, and on the first edit the old value is the initial one. Until you upgrade, you can guard the function: [c]const v = newValue?.value !== undefined ? newValue.value : newValue;[/c] and return early when [c]v[/c] is empty.