BUG: dates in virtual fields not working correctly after upgrade to 9.6.007

After upgrading to 9.6.007 virtual fields of type date in forms apps are not working anymore as expected.

In that version changelog there’s this entry:
“Fixed problem in formatting date/time fields when marked as a label.”

It’s not exactly my issue, but it makes me wonder if while fixing something related to dates, NetMake broke something else date related that was working…

Scenario to reproduce the error:

  • A form with two date fields.
  • One “real” (bound to the db) and one virtual created in the app.
  • The fields are set to use the regional setting and display this date format: “dd/mm/yyyy”
  • The form is run and both fields are populated with the same date:
    • field_from_db = “23/04/2021”
    • field_virtual = “23/04/2021”;

When read by any event, the fields return two different values:

  • field_from_db = “2021-04-23”
  • field_virtual = “23042021”;

The virtual one is obviously wrong and this was not happening before the upgrade to 9.6.007.

On one of the form events, my code reads the virtual field value and via sc_exec_sql() writes it in a db table date field. ‘23042021’ is not a correct slq date format and the db returns an error.

Again, this was not happening before the SC upgrade: the sql write was successful, hence the returned date value was formatted correctly.

Note that the “field_from_db” field in my example above is there only to be able to compare the behavior difference with the virtual field, I didn’t try, but I expect the issue to be detectable even with just the virtual field.

1 Like

Yep there’s defintely something wrong with virtual fields set as date.

That app has been working for at least one year with no date issues.

After spending hours fighting to solve the issue (see my previous post), as a workaround I just changed the fields from virtual (app based) to real (db based) ones.

Now the code on the events is able to get the correct date vaules as it was before the upgrade.

Defintely a bug introduced by upgrading SC.

Here’s the detail of the workaraound that made the app work again:

  • removed the virtual date fields in the app in SC
  • created new (real) fields in the DB server with exactly the same names I used for the virtual fields (the ones removed in the previous step)
  • in the app in SC performed a Syncronize Table so that the new real fields were added to the form as db date fields

Now when my code in an event reads the fields value it gets the correctly sql formatted value again.
E.g. “2021-04-23”
(before changing fields type, reading the fields returned “23042021”)

1 Like