With the JavaScript Adapter, you can integrate plain JavaScript services to applications in Kony Fabric.
You can upload custom JavaScript files to Kony Fabric. Using JavaScript adapters, you can easily create server-side code and make it available as operations. The JavaScript file must contain functions that a user wants to be made available as operations, along with other supporting functions. You can also add preprocessor and postprocessor to the operations defined. For more details on the structure for JavaScript function definitions, refer to the Limitations section.
For more details about the sample JavaScript code, refer to JavaScript Sample Code for Preprocessor and Postprocessor.
Based on the JDK version supported by Kony Fabric Installer, the JavaScript adapter uses the following JavaScript engines:
To configure JavaScript service in the Integration Service Definition tab, follow these steps:
Field | Description |
---|---|
Specify JavaScript libraries |
From the Specify the Javascript libraries section, select a .JS file, or click Upload to select the .JS file from your local machine. The console adds your JS file to the console. The system displays the added JS file's name under the Specify the Javascript libraries section. The system allows you to upload more than one JS file at Specify the Javascript libraries. Once uploaded, JavaScript files are available across Kony Fabric console. They cannot be deleted, only unlinked. You can unlink uploaded .JS files by clicking the Unlink icon. |
Note: All the fields in the Advanced tab are optional.
In the Description field, provide a suitable description for the service.
The Operation List tab appears when you click Add Operation in the Service Definition page.
Note: Click Operations List tab > Configure Operation. The Configured Operations list appears.
Click ADD OPERATION to create operations with the selected functions.
The new operations are created and listed under the Configured Operations.
Operation names are auto-generated in the format : <Name-of-the-JS-file>_<function-name>. For example, sample_addTwoNumbers
In the Operation Modal tab, provide the following details to configure an operation:|
Field | Description |
---|---|
Name | It is prepopulated with the operation name. You can change the name if required. |
Operation Security Level |
It specifies how a client must authenticate to invoke this operation. |
Description | Provide a suitable description of your operation. |
Note: All options in the Advanced section are optional.
Integration services accept only form-url-encoded
inputs for all the input parameters provided in the service input parameters (request input).
You can perform the following actions in Request Input tab:
Field | Description |
---|---|
Name | It Contains a Unique Identifier. Change the name if required. |
Test Value | Enter a value. A test value is used for testing the service. |
Default Value | Enter the value, if required. The default value will be used if the test value is empty. |
Value |
Select one of the following options. It is set to Request by default.
|
Data Type | |
Encode |
Select the check box to enable encoding of an input parameter. For example, the name New York Times would be encoded as New%20York%20Times when the encoding is set to True. The encoding must also adhere to the HTML URL encoding standards. |
Description | Provide a suitable description. |
To validate the operation details, click Save and Test. For more details, refer to Test a Service Operation.
Note: If you define parameters inside a record as the session, the session scope will not get reflected for the parameters.
In JavaScript service, the response (output) from a back end is not parsed based on the response values. The complete response from the back end is sent to the client device.
Note: By default, the opStatus
and httpStatusCode
values for Java and JavaScript services are added as 0 and 200.
To validate the operation details, click Save and Test. For more details, refer to Test a Service Operation.
If you click Cancel, the Operation Modal tab closes without saving any information.
Note: To add more operations for your JavaScript service, repeat Step 3 through Step 4.
Note: You can view the service in the Data Panel feature of Kony Visualizer. By using the Data Panel, you can link back-end data services to your application UI elements seamlessly with low-code to no code. For more information on Data Panel, click here.
The JavaScript Engine does not support some common JavaScript libraries and global JavaScript functions such as jQuery, setTimeout, setInterval or XMLHttpRequest. However, it provides an alternate mechanism to perform the same operation. You can invoke the required functionality using Java for such cases. For example, consider the XMLHttpRequest API. Since Nashorn does not support this API, you will need to use Java to perform the required operations. You can use URLConnection java class or HttpClient API to achieve the same goal.
function abc() { … }
Last updated on : 13 June, 2023 | Copyright © 2020 Kony, Inc. All rights reserved. |