Node.js files contain tasks that will be executed on certain events. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. Node.js applications are written in JavaScript, and can be run within the Node.js runtime.Node.js files have extension “._js”
STEP1: Creating Node.js File and save it as gumu.js
Writing Node.js code with build in modules and user defined modules and save it on Root Drive:\Sage\SyracuseComponent\syracuse\bin\node_modules\bundles\ greytrix\lib\gumu.js
Create the folder under bundles(greytrix\lib)
Fig 1.1-Code Description:
The “use strict” Directive:
“use strict”: Defines that JavaScript code should be executed in “strict mode”. It helps to write cleaner code, like preventing from using undeclared variables.
Built-in Modules:
To make Node.js act as an HTTP server include the module. Include the module using require() function with the name of the module.
Server:var http = require(‘http’);
Application has access to the HTTP module, and is able to create a server.
Node.js has a built-in module called HTTP, which allows Node.js to transfer data over the Hyper Text Transfer Protocol (HTTP).
To identity the httpclient we can declare
Client : var httpClient = require(‘syracuse-httpclient/lib/httpClient’);
Create user defined Modules:
Use the exports keyword to make properties and methods available outside the module file.
Example: exports.TOBASE64=function(_,InData){…..};
STEP2: Passing argument from x3 client

Fig 2.1-Code Description:
The function EXEC_JS is located in the ASYRWEBSER library and func ASYRWEBSER.EXEC_JS is used to execute node.js file and its definition is the following
MODULE:
- The name of the published node.js JavaScript module.
FUNCTION
- The name of the JavaScript function to be called.
MODE
- A mode to determine if the call is synchronous or asynchronous (‘sync’ or ‘wait’).
ARGUMENTS
- Multiple arguments delimited by ‘,’ ; It can be JSON format or every types.
ENCODINGS
- Specify if arguments must be base64 encoded or not. A list of ‘0’ or ‘1’ separated by ‘,’.
- Can be empty if no base64 encoding is needed for any argument.
- Important: when it is not an empty string, it must match exactly the number of arguments.
- Base 64_IN.
CALLB
- Specify the location of callback function. This is needed only for ‘wait’ mode.
- The value depends on the function.
- -1 is the value to say that the callback location is the last parameter.
RETURNS
- Used to filter JSON Objects .
RETURNS_ENC
- Specify the needs to encode the response to base64 or not. Can be ‘0’ or ‘1’
- Base 64_OUT
RESHEAD
- The http response header.
RESBODY
- The Response body. The response will be stored in this variable.
STATUSCODE
- The status code returned by the JavaScript runner module.
STEP 3: Output

Note: Restart the Sage Syracuse – NODE0 service when changes done on gumu.js file
This blog helps us to understand how to write encode function on node.js server by passing input parameter from X3 client.
About Us
Greytrix – a globally recognized and one of the oldest Sage Development Partners is a one-stop solution provider for Sage ERP and Sage CRM organizational needs. Being acknowledged and rewarded for multi-man years of experience and expertise, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third-party add-on development, and implementation competence.
Greytrix has some unique integration solutions developed for Sage CRM with Sage ERPs namely Sage X3, Sage Intacct, Sage 100, Sage 500, and Sage 300. We also offer best-in-class Sage ERP and Sage CRM customization and development services to Business Partners, End Users, and Sage PSG worldwide. Greytrix helps in the migration of Sage CRM from Salesforce | ACT! | SalesLogix | Goldmine | Sugar CRM | Maximizer. Our Sage CRM Product Suite includes addons like Greytrix Business Manager, Sage CRM Project Manager, Sage CRM Resource Planner, Sage CRM Contract Manager, Sage CRM Event Manager, Sage CRM Budget Planner, Gmail Integration, Sage CRM Mobile Service Signature, Sage CRM CTI Framework.
Greytrix is a recognized Sage Champion Partner for GUMU™ Sage X3 – Sage CRM integration listed on Sage Marketplace and Sage CRM – Sage Intacct integration listed on Sage Intacct Marketplace. The GUMU™ Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for the processing and execution of application programs at the click of a button.
For more information on our integration solutions, please contact us at sage@greytrix.com. We will be glad to assist you.