OIC and Javascript
Ø
Javascript can be used to perform additional
level of validations or business validations. This post will provide some basic
understanding on how to use a Javascript.
1.
First create a Javascript File, a filename with ‘.js’
extension. There can be more than one functions but during registration there should
be atleast one function.
2.
Configure the metadata in the library. The
function can then be used in the integration.
Ø
Datatypes supported by OIC for calling
Javascript function-
1.
String, Number, Boolean and Return
Ø
What to do if the Javascript input is an Array.
1.
Create a function using input as a string.
Convert the string into array using the below –
function myArrayProcessor(myArray) {
var status = 'FAILED';
var data = myArray.replace(/'/g,
'"');
myArray = JSON.parse(data);
for (i=0; i<myArray.length; i++) {}
return status;}
Ø
From the integration pass the array as a string
to the Javascript function. The input string will be parsed as an array in the
Javascript function itself.
1.
If there are more than 1 Javascript files. Then
create a Jar file and register in OIC.
Ø
To debug Javascript code use an instance of
CXConsole() like in the sample code below.
2.
var console = new CXConsole();
console.log("# Variable: ", variable);
Ø
OIC has a javascript function thread execution
duration of 1500ms. OIC automatically cancels the thread which runs beyond
1500ms.
If you have any questions : please mail to : kavi.dhiresh@hotmail.com
function myArrayProcessor(myArray) {
var status = 'FAILED';
var data = myArray.replace(/'/g, '"');
myArray = JSON.parse(data);
for (i=0; i<myArray.length; i++) {}
return status;}
console.log("# Variable: ", variable);