Null data values are represented in MessageValue objects, belonging to a MessageValue collection that is created from the data message sent by the server.
This document refers to example HTML. You can see the example HTML by downloading the hybridapp_null_value.zip file and extracting the hybridapp_null_value.html file.
In the example, MessageValueCollection is referenced by var values = myDataMessage.getValues();” and myDataMessage is created in the onHybridAppLoad method.
A specific MessageValue is referenced by values.getData(string key). If you use the Hybrid App designer, the IDE manages keys for you but with JavaScript API, you have to implement key management in the code yourself.
<input class="right" type="number" id="Nullvaluetest_int_value2_attribKey" sup_allows_null="true" sup_valuechanged="false" onchange="inputChanged(this)"/>
So if you want the MessageValue object corresponding to that control:
var value = values.getData(“Nullvaluetest_int_value2_attribKey”);
var isNull = value.getNullAttribute();
HTML usually puts an empty string into a control if it is assigned a null value. If the control is not changed but you get the data from it for its MessageValue object, the MessageValue object will have an empty string as its value instead of NULL. This means the NullAttribute is not set properly unless you set it yourself.
When using null values, keep in mind that the contents of the control do not tell you whether it should be null. This can cause bad data on the server. Putting an empty string into a number type MessageValue can throw a formatting exception on the server, so when using JavaScript API, you are responsible for maintaining null values.
This section references the hybridapp_null_value.html file to show examples of how to implement null values.
<input class="right" type="number" id="Nullvaluetest_int_value2_attribKey" sup_allows_null="true" sup_valuechanged="false" onchange="inputChanged(this)"/>
hwc.processDataMessage = function(incomingDataMessageValue, noUI, loading, fromActivationFlow, dataType)
<input class="right" type="number" id="Nullvaluetest_int_value2_attribKey" sup_allows_null="true" sup_valuechanged="false" onchange="inputChanged(this)" />
inputChanged uses another special attribute to indicate that the user has put something in the control and it is no longer null.