[bug-13810]DateTime input binding not working correctly

Hi have a DateTime Input component, pickerType = time, with the formattedValues time value bidirectionally bound to a memory (string) tag. At runtime, I can use the time picker and the bound tag updates. But when I close and reopen the view, the component has reverted back to whatever time was on the selector when the display was saved. If I change the time, it again updates the memory tag, e.g.

Open display, time spinner and memory tag set to 03:00
Adjust time spinner to 05:30. Memory tag updates
Close and re-open display. Spinner displays 03:00; memory tag remains at 05:30
Click spinner arrow for increment minute. Spinner displays 03:01. Memory tag updates to 03:01

Is it something to do with how I’m using my bindings, or is this a bug?

This looks like a bug on our side - those components are missing code to support bidirectional value changes.

1 Like

@ASF
This is what I get for skimming posts. I didn’t notice that you were using the formatted properties to try to do bidirectional writes; those properties deliberately don’t support writeback to update the value, just like the formatted properties on datetime components in Vision.

What you could do is keep your existing binding, and add a valueChanged script that does whatever logic you prefer to update the value property after the time property changes. Pay close attention to the origin parameter in the valueChanged script, so you don’t end up in an infinite loop.

Thanks. Is there a better way to achieve what I’m trying to do?

Basically, I just want to extract the minutes and seconds from the component into two separate integer tags - the way I made it work was to use that binding with a string tag, and then run a tag change script on that string tag to extract the hour and minute values and update the two integer tags - giving me an hour and minute of each day that a certain action is taken. Couldn’t seem to make any other way work correctly, but if there’s a better/more correct way of doing it I’ll happily tweak my approach.

There’s not really a strictly better approach - in Vision, I would recommend using a formatted text field to handle time input, since you don’t really need a full-fledged datetime selector. You could use a text field and some input validation on the value property - just check whether it’s a string that looks like a time, send it to the tag if it is, otherwise reject the value and reset back to the tag value.

1 Like