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
0
Comments
Can you set the date to a certain value 1-1-1980 and in the onvalidate or onmodify of the page clear it..
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