Quantcast
Viewing all articles
Browse latest Browse all 1519

How to write encode function on node.js by passing input argument from X3

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)

Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Fig 1.1 : Node.js File

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

Image may be NSFW.
Clik here to view.
Fig 2.1: X3 script file

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

Image may be NSFW.
Clik here to view.
Fig 3.1: Encoded 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 Partner is a one-stop solution provider for Sage ERP and Sage CRM organizational needs. Being acknowledged and rewarded for multi-man years of experience, 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 caters to a wide range of Sage X3, a Sage Business Cloud Solution, offerings. Our unique GUMUImage may be NSFW.
Clik here to view.
™
integrations include Sage X3 for Sage CRMSalesforce.com, Dynamics 365 CRM and Magento eCommerce along with Implementation and Technical Support worldwide for Sage X3. Currently we are Sage X3 Implementation Partner in East Africa, Middle East, Australia, Asia, US, UK. We also offer best-in-class Sage X3 customization and development services, integrated applications such as POS | WMS | Payment Gateway | Shipping System | Business Intelligence | eCommerce and have developed add-ons such as Catch – Weight  and Letter of Credit and India Legislation for Sage X3 to Sage business partners, end users and Sage PSG worldwide. Greytrix Sales Commission App for Sage X3 simplifies commission calculations and postings on sales transactions.

The GUMUImage may be NSFW.
Clik here to view.
™
Cloud framework
by Greytrix forms the backbone of cloud integrations that are managed in real-time for processing and execution of application programs at the click of a button.

Greytrix is a recognized Sage champion ISV Partner for GUMUImage may be NSFW.
Clik here to view.
™
Sage X3 – Sage CRM integration also listed on Sage Marketplace; GUMUImage may be NSFW.
Clik here to view.
™
integration for Sage X3 – Salesforce is a 5-star rated app listed on Salesforce AppExchange and GUMUImage may be NSFW.
Clik here to view.
™
integration for Dynamics 365 CRM – Sage ERP listed on Microsoft AppSource.

For more information on Sage X3 Integration and Services, please contact us at x3@greytrix.com, We would like to hear from you.


Viewing all articles
Browse latest Browse all 1519

Trending Articles