Inconsistency reading and writing data to page webservices

JaapJaap Member Posts: 7
edited 2011-11-01 in NAV Three Tier
I see inconsistencies between the data you are reading from a page webservice and the data you write to a page webservice when dealing with ‘empty’ fields.

When you look to a string field (Text, Code), if this is empty in NAV (SQL: a string with 0 length, not NULL!). When reading that value with a webservice, you get a null string. But when you want to update that field with an empty value, you need to send a string with 0 length (as null means in a webservice that you don’t want to change the field).

With a string field, we can work around it, but with Date/Time/Datetime fields we have a bigger problem. When that field is empty in NAV (in SQL represented as 1/1/1753 0:00:00; Minimum real value in NAV is 1/1/1754 0:00:00), the webservice is returning a DateTime.MinValue (1/1/1 0:00:00) which is fine. But when I want to clear such a field through the webservice, it would be logical to send a DateTime.MinValue, but the webservice does not accept any value below 1/1/1754 0:00:00. And I have not found the ‘magic’ value which clears a date/time/datetime field. So it is not possible at all to clear a field.
With a Time field we have an additional problem. As said above an empty field is in SQL represented as 1/1/1753 0:00:00 and for a non-empty time field the date part in SQL is always 1/1/1754. But in the webservice 1/1/1 is always returned as date part. So an empty field is returned as 1/1/1 0:00:00 and a zero value (0:00:00) is also returned as 1/1/1 0:00:00. So I can’t distinguish between and empty and zero value.

(Big)Integer, Decimal, Boolean, Duration, Option and Guid fields don’t have this inconsistency, because they don’t have the notion of ‘empty’ fields, at least at the data level. Of course in NAV you have in the UI the option to define in the metadata that some values should be displayed as blank. But that is at the UI level and does not affect the data level and the webservice.

In my opinion there should be no difference in meaning of the data you get from a webservice and you send to a webservice.
An beside that: is there anybody who has found the ‘magic’ value to clear Date/Time/Datetime fields?

Thanks, Jaap

Comments

  • mdPartnerNLmdPartnerNL Member Posts: 802
    An idea :mrgreen:

    Can you set the date to a certain value 1-1-1980 and in the onvalidate or onmodify of the page clear it..
  • JaapJaap Member Posts: 7
    Well, could indeed be a workaround for clearing a date/time/datetime field, although it is not generic at all :( Need to do it for every field

    In my opinion the only real solution would that Microsoft changes the inner working of the webservice. Whould be a non-breaking change in this case, so would not be a bit issue to change.

    The issue with no difference between reading an empty or zero time value is still another topic
  • DuikmeesterDuikmeester Member Posts: 308
    Just a thought, and not tested, but is it not possible to set the property to NULL and propertySpecified to true?
  • JaapJaap Member Posts: 7
    That is not possible because a DateTime is a valuetype and not a reference type. And value types can't be null. So it defaults to 1/1/1 and that is not accepted by the server as I wrote above
Sign In or Register to comment.