Data Type Mapping Between Uniface and JavaScript

Uniface provides implicit data type mapping between Uniface and JavaScript for data fields.

These mappings are also applied when using $widgetoperation to call a JavaScript function in the HTML widget with parameters, and for OUT parameters returned to the browser after activating an operation using the activate() JavaScript API.

JavaScript has other data types then Uniface, so the translation might not be performed without loss. The original Uniface data type might be unknown in JavaScript.

For example, Uniface date and time data types are both mapped to the JavaScript Date object type. The JavaScript program must be able to distinguish whether the JavaScript Date is a time or a date value. For example, using getMonth() on a JavaScript Date is not relevant when it originates from a Uniface time.

When no implicit mapping is available, the error -1118 is returned. To avoid this, you can explicitly convert the parameter to a string (or other accepted data type) before calling the operation. For example, you can use $encode ProcScript function to convert Uniface raw data to a base64 string before it is passed to JavaScript. The JavaScript function can convert this string to an appropriate JavaScript object.

Uniface does not have explicit NULL value handling. NULL values are mapped to a JavaScript variable with a null value. Empty or uninitialized values are mapped to JavaScript as null. However, for string-based mappings, you should use " " to pass an empty string .

Data Type Mappings Between Uniface and JavaScript
Uniface Scalar Data Type JavaScript Object Type
Boolean Boolean
Date Date (only date part set)
DateTime Date (local time)
Float Number
Image — or base64 encoded string
LinearDate
LinearDateTime
Numeric Number
Raw — or base64 encoded string
String String
Time Date (only time part set, see setTime() )
XmlStream String