Bool fields in BusinessPackDataSet never become false

siteData is defined in the ViewModel as:

public BusinessPackDataSet siteData { get; set; } = new BusinessPackDataSet()
{
PagingOptions = { PageSize = 100 },
SortingOptions = { SortExpression = nameof(OfficeHoursViewItem.SiteName) },
RowEditOptions = { PrimaryKeyPropertyName = nameof(OfficeHoursViewItem.siteId), EditRowId = -1 }
};

The OfficeHoursViewItem class is relatively simple and contains the following boolean fields (among others):

public bool bMondayOfficeClosed { get; set; }
public bool bTuesdayOfficeClosed { get; set; }
public bool bWednesdayOfficeClosed { get; set; }

What you see in the image is the state of everything upon initially clicking “Edit”.

bMondayOfficeClosed = true
bTuesdayOfficeClosed = false
bWednesdayOfficeClosed = true

If I change the bTuesdayOfficeClosed variable from the original “false” to “true”, it immediately changes to “true” in the live expression viewer.

If I change any of the “true” values to “false”, the variable DOES NOT change to “false” in the live expression viewer and upon clicking “save” to the row edit, the variables return to the server as “true” even though it appeared to be “false” in the edited row.

I’ve tried a couple other values (such as “!true”, “FALSE”, and “0”) in an attempt to find anything that does evaluate to false but anything I’ve tried other than “false” itself results in a client-side “Cannot coerce …” error.

Are there any other way you can think of to get a “false” value to get parsed and passed back to the ViewModel properly?

I’ve confirmed identical behavior on another bool field on a different BusinessPackDataSet on a separate page.

How exactly are you trying to set the property?

state.A.B.C = false expressions do not work by design, as the state objects are copy-on-write to enable change cheap tracking. If you want mutable object API, you can use dotvvm.viewModels.root.viewModel.A().B().C(false). See Read & modify viewmodel from JS | DotVVM Documentation

I’m updating it via the form on the page and just observing the changes through the console.

If I change it from false to true on the single-line edit on the form, I see it change immediately in the console.

If I change a true value to false on the single-line edit on the form you never see it change in the console and when you fire the save a true is sent back to the view model server side.

Sorry, I missed that. This is a bug in the type conversion which is currently only fixed in the 4.3 preview version. We didn’t want to backport this to 4.2, as it may not be completely safe to update. Could you please try updating DotVVM to 4.3 (no need need to update BusinessPack)

1 Like

I’ll try that first thing Monday morning, eastern US, and let you know how it goes.

This appears to be fixed in version 4.3-preview04-final!

Anything in this release that we should watch out for as we continue our 2.x → 4.x upgrade testing?

Great, thanks for verifying that. I’m not aware of similar regressions. However, we rewrote approximately everything since 2.x, so it is very much possible that you’ll encounter something. Definitely let us know if you find some other issue.