After tinkering around with our "onChangingValues"-function some more we managed to get it to work, with a tiny modification.
Originally our code looked something like this:
..and when the value for "number2" didn't change "getFormattedValue" would return "null", so the formatting didn't work, and the unformatted value would be inserted in the "DynaScrollTable".
Out of curiosity I changed the code to use "getServerValue()" instead of "getFormattedValue()", and all of a sudden it worked. The only thing I did was to change the line
Code:
var number2 = itemUpdate.getFormattedValue("number2");
to
Code:
var number2 = itemUpdate.getServerValue("number2");
After putting some debug output in our function to see the values for "getServerValue()" and "getFormattedValue()" it showed the following:
- When the value for field "number2" changes in an update the new value is supplied identically via both functions (e.g. both functions return a value of "123.45")
- When the value for field "number2" does not change in an update, "getFormattedValue()" returns "null" - but "getServerValue()" returns the last received value
Even though our code now works correctly, and the problem we had before is explained after the debug output, I still find the behaviour of the web client somewhat strange.
"getServerValue()" doesn't puzzle me, it returns the last known value, no matter if it was received with this update, or with a previous one - in effect it always returns the latest value the server sent/knows for the field, exactly what the name of the function implies.
"getFormattedValue()" on the other hand doesn't really do what the name implies. When there is an update for the field, then the function intially returns the same value as "getServerValue()" does, which is the unformatted value sent by the server. Only if I manually call "setFormattedValue()" a subsequent call to "getFormattedValue()" will return something different - but as I already know what that value is (as I just set it before) I don't see the benefit of using "getFormattedValue()". And if there is no update for the field, then "getFormattedValue()" does not return the last known formatted value (which would make it behave similar to "getServerValue()"), but instead it returns "null" - and if I don't set it to something sensible (by accessing "getServerValue()" and setting the formatted value by calling "setFormattedValue()") the unformatted value will be displayed on the website.
The way I see it, in order to make sure that everything is formatted correctly on the website, I always have to format each field by accessing "getServerValue()" and setting "setFormattedValue()", no matter if that field did actually change in the last update or not, because if I don't do so the web client library will display the wrong unformatted value instead of the correct formatted value of the previous update - even though the library ideally should still know the previously formatted value which would make the redundant formatting of unchanged values unnecessary.
Bookmarks