Custom function in OIC | Using Libraries to Manage Functions for Integrations
– Advertisement –
In this blog we will see how to define custom function in OIC and then use it inside our Integration.
Use Case :
Our requirement is to convert date format “20-MAR-95” into this format “20-03-2095”. As we don’t have any function as of now present in OIC to full fill this requirement , so we will define a CUSTOM FUNCTION (in JavaScript) and later use this function in an Integration.
Approach :
- Firstly, we will register the Libraries that is containing our CUSTOM JAVASCRIPT FUNCTION. Once it get registered , libraries functions are automatically available for us to drag and drop from Actions palette for orchestration Integrations.
- Secondly, we will use this custom function in one integration.
- Thirdly, Testing of Integration.
Lets see the steps in detail :
STEP 1:
In OIC home page , click Libraries icon present inside the left Designer navigation bar.
- Click the Register button in the tittle bar.
– Advertisement –
- In the Register Library dialog box, click browse to select the above saved file “convertDateFormat.js”
Description : write some meaningful description & click create.
- The libraries page will open , select convertDateFormat.js as shown in below image
- select XPath , click Save and then close
Registration of libraries that contain our custom function “convertDateFormat” is completed. Now we can use this custom function in our integrations.
Now let’s create an Integration to use above registered custom function “convertDateFormat”
- From the left Designer navigation bar present in OIC home page, click Integration and then click Create
- Select App Driven Orchestration
– Advertisement –
App Driven Orchestration ? : It enables you to create an integration that uses an event or business object to trigger the integration. In laymen’s terms – you have to pass some inputs to trigger the app driven orchestration integrations.
- Enter the below details and then click Create :
*What do you want to call your Integration? – write some meaningful name
*What can this Integration do? – write some meaningful description
- Search for the REST connection name ‘RESTConnection’ and Select it.
( You can access this blog to configure this REST connection )
- Enter the below details and click Next – [as shown in below image ]
*What do you want to call your endpoint ? : write any meaningful name
*What is the endpoint’s relative resource URI ? : write /date
(you can give any meaning full word with “/” )
*What action do you want to perform on the endpoint ? : Select POST
&
Select Configure a request payload for this endpoint
Select Configure a response payload for this endpoint
- Select JSON Sample and then click inline to add request payload [as shown in below image ]
– Advertisement –
- Enter sample JSON → {“Input Date Format” : “”} and click OK and then click Next
- Similarly configure response payload :
Enter sample JSON → {“Output Date Format” : “”} and click OK and then click Next.
- Click Done.
- Open the Mapper by clicking Edit icon.
– Advertisement –
Click the icon as shown in below image to see your custom function “convertDateFormat” which we have configured in STEP 1.
Right click at response column and then select Create Target Node
- Now drag and drop the custom function from left pane inside popup window and then drag and drop the request column inside this function call and then click Validate and then Close.(as shown in below image )
- Enable tracking by clicking Hamburger sign and then click Tracking
- Map the request column as tracking variable and then click Save and Close.
– Advertisement –
- Click Save and Close. Your Integration is ready to TEST.
- Activate the above integration
- Click on endpoint URL
- Copy the endpoint URL
- Now, Open SoapUI tool (5.5.0) to Run the above integration:
SoapUI? : It is an open source web service testing application.
- Click on REST ,Then Paste the above copied endpoint URL and then click OK
- Configure the REQUEST PAYLOAD ( as shown in below image):
- paste below request sample in request payload box
{“Input Date Format”:”20-MAR-95″}
Authorization : add Basic authorization (enter your OIC userid
and password )
– Advertisement –
You may also like
11 comments
Leave a Reply Cancel reply
Archives
- November 2024
- October 2024
- May 2024
- June 2023
- December 2022
- October 2022
- September 2022
- June 2022
- May 2022
- April 2022
- March 2022
- February 2022
- January 2022
- December 2021
- November 2021
- August 2021
- July 2021
- May 2021
- March 2021
- January 2021
- November 2020
- October 2020
- September 2020
- May 2020
- March 2020
- February 2020
- January 2020
- December 2019
- August 2019
- July 2019
- June 2019
- May 2019
- March 2019
Calendar
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | |||


























Nicely explained the basics of custom javascript library
Thanks Pankaj 🙂
Excellent example, thank you!
welcome 🙂
Excellent Dear, Thanks you very much. God bless you my dear
Welcome 🙂
Can I use a npm package to do more complex things?
try it from your side by doing one POC and let us also know the result
Can we Create PL/SQL function in OIC Libraries
dear I am not sure, but you check by doing some small POC
I have to write a Library to change a date in UTC, to Belgian time. (Which changes due to DaylightSavingsTime). But my question is does OIC supports basic libraries from javascript or?
If I run this local it works but on OIC it does not.
function convert_to_belgiantime(param) {
//console.log("Entered date Parameter: " + param + "\nCorrect date Parameter: " + param.replace(" ","T") + "+00:00\n\n")
var datetoconvert = new Date(Date.parse(param.replace(" ", "T") + "+00:00"));
console.log(datetoconvert.getTimezoneOffset());
var options = {
hour12: false,
timeZone: "Europe/Brussels",
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
};
var datetotest = datetoconvert.toLocaleString("nl-BE", options);
var dateconverted =
"Converting date \n" + datetoconvert + "\n to \n" + datetotest;
return dateconverted;
}