Blog navigation

Derniers articles

Javascript

A standard API is available in X3 scripts to perform calls to the platform's javascript published functions. It works on code executed from classic pages as well as on V7 (and later) code.

The execution of functions is performed on node.js in javascript. A function can be synchronous or asynchronous. When a function is asynchronous, a parameter of the function defines the callback function; i.e., the function that is called when the execution of the asynchronous function is finished. We use the package streamline.js to make the use of asynchronous functions simple, by adding an "_" parameter that is preprocessed to handle the callback.

This means that if the function has been defined as asynchronous, you have to use the 'wait' value for MODE, and to indicate the place of the callback parameter as it is declared in the function. The values of these parameters will be mentioned in the function definition.

The function fills RESBODY and RESHEAD, and returns the HTTP status (200 if successful).

The complete JSON structure returned is stored in RESBODY as a stringified JSON. If you want to get only one element in the structure, you have to give its name (if it is a property at the first level of the hierarchy) or the path (if it is a nested property). If the property is a single one, it will be returned in a string, otherwise you will get the JSON description of the requested sub-element.

For example, if the function returns a JSON like the following one:

  • EXEC_JS / streamline.js / Sage X3 Syracuse Javascript bundles
    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...

    Read more