Blog navigation

Derniers articles

EXEC_JS / streamline.js / Sage X3 Syracuse Javascript bundles

Sage X3 4GL is sometimes limited when you need to develop with cryptographic functions.

Sage intented to workarround this limitation by creating a « bridge » between 4GL and javascript.

Basically it’s possible de create Javascript functions that can be deployed at Syracuse level within the node.js framework and called from Sage X3.

This is also how the editor is managing complex functions like « Chorus »

It’s very convenient for several cases :

- Multiple complex certificate expected to communicate within a webservice and not managed by Syracuse due to their encryption method or number limitation.

- Function not existing in 4GL

- Parsing method more evolved within Javascript

In order to setup a Javascript bundle module there are plenty of article explaning how to perform the process

Online Help > search for keyword « javascript bundles »

This article intend to help you for 2 aspects not detailed in the official documentation whom can lead to several days of nightmare.

Asynchronous vs Synchronous

Sage X3 is an synchronous program awaiting for any line of code to finish executing before going to the next one.

On the other hand you have Javascript witch is asynchronous, several lines with different command can be executed simultaneously.

This concept is not linked to the way you code it in javascript and it’s natively incorporated in some method that cannot be technically synchronous.

Exemple : I/O on files or http GET …

So 4GL is able to trigger the javascript function but doesn’t wait nor knows when it finishes and goes to check immediatly the body result that is blank and no error are returned in the log file.

This behaviour is « normal » considering javascript as asynchronous and 4GL as Synchronous, it’s similar to a printing order.


In order to fix this issue, Sage invented a javascript layer called « streamline.js »

This layer is able to convert any asyncrhonous javascript function to synchronous.

In order to use it it’s very important to respect some basic rules.

- Your javascript file extension needs to be « ._js » and not « .js »

It’s very confusing but it’s used by the layer to make the trasnformation possible.

- You need also to integrate a callback in your Javascript function.

This callback it’s not a javascript classic one, and it’s materialized by an underscore in the javascript function.

Testing and debugging

In order to verify your javascript code you can instaciate node.exe process with your javascript file

But you will need to fix your javascript code without callback first and then implement the callback notion.

Publié dans: Sage X3, 4GL, Javascript