JavaScript ES6 Support
By default, the FintechOS Platform uses a Jint JavaScript interpreter with full support for the ECMAScript 5.1 language specification (ES5) to run the server automation scripts. Starting with release 22.1.4, an alternate scripting engine based on the Microsoft ClearScript library allows you to work with JavaScript using the ECMAScript 6 language specification (ES6) (and also to Use the Debugging Server).
Switch between the Jint (ES5) and ClearScript (ES6) Scripting Engines
To change the JavaScript scripting engine, use the sys-workflowengine-enable-debugging
system parameter:
- 0 - Enables the Jint (ES5) scripting engine (default).
- 1 - Enables the ClearScript (ES6) scripting engine.
For more information, see System Parameters.
ES6 Compatibility Impact
If you switch from the Jint (ES5) to the ClearScript (ES6) scripting engine, make sure that your legacy code meets the ES6 language specifications. Some of the potential compatibility issues are listed below.
The JavaScript Date Object Is Always Set to UTC
A DateTime object constructed from a JavaScript Date object always represents a Coordinated Universal Time (UTC) and has its Kind property set to UTC.
The EnableDateTimeConversion flag specifies that the script engine will perform automatic conversion between .NET DateTime objects and JavaScript Date objects. This conversion is bidirectional and lossy.
This should not impact your existing code, since FintechOS Platform installations are set to UTC by default. For example, the code below returns the same values for Jint and ClearScript engines, with the observation that every DateTime value is converted to UTC:
let date = new Date();
let dateFromParts = new Date(date.getFullYear(), date.getMonth(), date.getDate());
setData({
date: date,
dateFromParts: dateFromParts,
invariant_date: new InvariantDate(date),
invariant_dateFromParts: new InvariantDate(dateFromParts),
invariantFromParts_date: new InvariantDate(date.getFullYear(), date.getMonth() + 1, date.getDate()),
invariantFromParts_dateFromParts: new InvariantDate(dateFromParts.getFullYear(), dateFromParts.getMonth() + 1, dateFromParts.getDate())
});
Enforced ES6 JavaScript Syntax
ClearScript enforces strict ES6 JavaScript syntax, while Jint has a more relaxed syntax interpretation. Some of the situations that were not treated as errors by Jint, but are reported as syntax errors by ClearScript are listed below:
- If an object is declared with UPPERCASE property names, the same case needs to be used when reading those properties.
- Declaring the same variable multiple times.
- Using
InvariantDate().today
throws an exception. The correct ES6 syntax isInvariantDate.today
. For more information, see the Server SDK documentation.
Processor Settings
When working with automation blocks, the JSON settings and mappings must be correctly formatted - if you add a comma (',') after the last array element, you will receive an error similar to:
EBS.Core.Data.Services.DataConverterException:
The value for attribute unpaidAmount on entity FTOS_PYMT_OutgoingPayment could not be converted to a valid entry.
Attribute type: numeric ---> System.InvalidCastException: Unable to cast object of type 'Microsoft.ClearScript.Undefined' to type 'System.IConvertible'.
Use the no-code capabilities of the FintechOS Platform to edit automation block settings and mappings.
Numeric Attributes and Undefined Variables
Updating a numeric attribute with a variable that is undefined will trigger an error.
EBS.Core.Data.Services.DataConverterException:
The value for attribute unpaidAmount on entity FTOS_PYMT_OutgoingPayment could not be converted to a valid entry.
Attribute type: numeric ---> System.InvalidCastException: Unable to cast object of type 'Microsoft.ClearScript.Undefined' to type 'System.IConvertible'.
server.query.getAlias Case Sensitive Attribute Names
Fluent query field names are now case sensitive. For instance, assuming an entity with an option set attribute named Os1, using case insensitive alias field names works with Jint, but doesn’t produce the same results with ClearScript:
var E1 = server.query.getAlias("FTOS_Entity");
var O1 = server.query.getAlias("OptionSetItem");
var vresults = server.query.from(E1)
.leftJoin(O1).on(O1.OptionSetItemId.eq(E1.op1))
When ClearScript is enabled, E1.op1
evaluates to undefined and the result of the query execution is different (it translates to an SQL join clause of O1.OptionSetItemId is null).
The correct syntax for ClearScript is:
var E1 = server.query.getAlias("FTOS_Entity");
var O1 = server.query.getAlias("OptionSetItem");
var vresults = server.query.from(E1)
.leftJoin(O1).on(O1.OptionSetItemId.eq(E1.Op1))