Inconsistency reading and writing data to page webservices

Jaap
Member Posts: 7
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
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
-
An idea
Can you set the date to a certain value 1-1-1980 and in the onvalidate or onmodify of the page clear it..0 -
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 topic0 -
Just a thought, and not tested, but is it not possible to set the property to NULL and propertySpecified to true?0
-
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 above0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions