Use Libraries to Manage Functions for Integrations

JavaScript libraries provide a means to create and organize JavaScript for use in integrations. Library functions are automatically available for you to drag into your orchestration integrations.

You can use the library functionality to:

  • Create a new JavaScript library

  • See a list of all created JavaScript libraries

  • View the details of a JavaScript library

  • Edit the details of a JavaScript library

  • Determine which integrations are using library functions

  • Delete a JavaScript library

  • Import functions

  • Download a library source file to your desktop

  • Add library functions from the orchestrated integration'sActions menu palette.

Create a JavaScript Library

In order for custom function calls to appear in the integration Actions palette, you must create the libraries that contain them.

  1. In the left navigation pane, click Home > Integrations > Libraries.
  2. Click Create in the banner.
  3. In the Create Library dialog box, click Browse to select a JavaScript (.js) library file.
  4. Specify a name, identifier, version number and optional description.

Example 7-1 Code Format

Function return parameters must be named like the example below. You should configure the return parameter type in the metadata user interface only if the return parameters are named.

Consider the following code:

function add ( param1, param2 )
 {    return param1 + param2;
}

Although the above syntax is valid, the return parameter does not appear in the metadata user interface for configuration. For that to happen, the code must return a named parameter. Create a new variable and assign return values before the variable is returned. For example, like this:

function add ( param1, param2 ) {
   var retValue = param1 + param2;
   return retValue;
}

Example 7-2 Function Within Another Function

Functions defined within another function do not appear in the metadata user interface for configuration.

 Consider the following code:

numeric.parseDate = function parseDate(d) {
    function foo(d) {
        if(typeof d === 'string') { return Date.parse(d.replace(/-/g,'/'));} 
     if(!(d instanceof Array)) { throw new Error("parseDate: parameter must be arrays of strings"); }
     var ret = [],k;
     for(k=0;k<d.length;k++) { ret[k] = foo(d[k]); }
        return ret;
    }
     var retVal = foo(d);
     return retVal;
   }

In this case foo is defined within parseDate. Therefore, foo does not appear in the metadata user interface for configuration.

View Library Details

View details about a library without changing any information.

  1. In the left navigation pane, click Home > Integrations > Libraries.
  2. Go to the row of the library to view.
  3. Click View link.

    The files and their constituent functions are displayed. You can expand and contract the list of functions and you can search and filter the list as well. To view information about a function, click on the function. To view the source code, click on the file name and download the code to your desktop. You can also click on the file name to annotate the entry with your comments.

  4. Use the Menu icon menu on this page to view primary information about the library and to export XML metadata to your desktop.
  5. When done, click Go back icon to return to the Libraries page.

Edit Library Details

Edit details about a library.

  1. In the left navigation pane, click Home > Integrations > Libraries.
  2. Either click the library name or click Edit link.

    The files contained in the library and their constituent functions are displayed. You can expand and contract the list of functions, and you can search and filter the list. To edit information about a function, click on the function. To view the source code, click on the file name and download the code to your desktop. You can also click on the file name to annotate the entry with your comments.

    If the function is in use in an integration, you are warned about it and the function is presented in view-only mode.

    If the function is available for editing, you can set the data types of the function’s input and output values, defining them as Boolean, Number or String. You can also add a description.

    You can use the Menu icon menu on this page to:

    • View primary information about the library

    • Export XML metadata to your desktop

    • Import XML metadata from your desktop

    • Delete the library

  3. When done, click Save in the banner.

Determine Which Integrations Use a Library Function

You can determine which integrations are using functions in a given library.

  1. In the navigation pane, click Home > Integrations > Libraries.
  2. Go to the row of the library to check.
  3. In the Usage column, click the number. This value indicates the number of integrations that use functions in this library.
    When you click the number, the Library Is In Use dialog is displayed. It lists the names of the integrations that use the library’s functions. This dialog is also invoked if you attempt to edit or delete a library that is currently in use.

Note:

If you attempt to activate an integration that includes a function that is not completely configured, an error message is displayed in the banner. You must complete configuration of this function before you can activate the integration. See Activate an Integration.

Delete a Library

Delete a library.

  1. In the left navigation pane, click Home > Integrations > Libraries.
  2. Go to the row of the library to delete.
  3. Select Delete from the Actions menu menu.
    If any of the library’s functions are being used by an integration, the Library Is In Use dialog is displayed and you are prevented from deleting the library. You must remove the functions from the integration before you can delete the library.

Import a Library File

You can import a library ZIP file into Oracle Integration. The ZIP file must contain only the library JAR and metadata XML file.

  1. In the left navigation pane, click Home > Integrations > Libraries.
  2. Click Import in the banner.
  3. In the Import Library dialog box, click Browse to select the ZIP file.
    The Javascript Library page is displayed.
  4. Make updates, as necessary, then click Save.

Download a Library File

You can download a library to a source file (.jar or .js) on your desktop.

  1. In the navigation pane, click Home > Integrations > Libraries.
  2. Go to the row of the library to download.
  3. Select Download from the Actions menu menu.
  4. Click Save File to save the file to your desktop.

Update Library Functions

You can update an already created library with an updated Javascript file.

Note the following guidelines for updating a Javascript file:
  • Functions (within a library) used in integrations must be available in the updated Javascript file.
  • The signatures (parameters and function name) for these functions must remain intact to prevent runtime issues.
  • The addition of new functions is allowed.
  • Active integrations using new or updated functions must be reactivated.

The following changes make an updated Javascript file invalid:

  • Changing the name of a function being used in an integration.
  • Changing the parameter definitions of functions used in an integration.
  • Structural issues with the Javascript file.
  • The number of functions exceeds 500.
  1. In the left navigation pane, click Home > Integrations > Libraries.
  2. Find the library to update.
  3. Select Update from the Actions menu menu. For example, assume the library to update includes four functions, one of which (multiply) is currently being used in an integration.

    The content of the library is as follows:
    function add ( param1, param2 ) {
         var retValue = param1 + param2; 
         return retValue;
    }
    function subtract ( param1, param2 ) {
         var retValue = param1 - param2; 
         return retValue;
    }
    function multiply ( param1, param2 ) {
         var retValue = param1 * param2; 
         return retValue;
    }
    function divide ( param1, param2 ) {
         var retValue = param1 / param2; 
         return retValue;
    }
  4. Click Choose File to select the Javascript file that includes the function updates, then click Update.

    Update Function Dialog with Choose File button, Update button, and Cancel button

    For this example, the Javascript file consist of the following updates:
    • Two new functions: add_three, multiply_three
    • One removed function that was not being used by any integrations: subtract
    • A code change to the multiply function that is currently being used in an integration
    function add ( param1, param2 ) {
         var retValue = param1 + param2; 
         return retValue;
    }
    function multiply ( param1, param2 ) {
         var retValue = param1 * param2 * 2; 
         return retValue;
    }
    function divide ( param1, param2 ) {
         var retValue = param1 / param2; 
         return retValue;
    }
    function add_three ( param1, param2, param3 ) {
         var retValue = param1 + param2 + param3; 
         return retValue;
    }
    function multiply_three ( param1, param2, param3 ) {
         var retValue = param1 * param2 * param3; 
         return retValue;
    }

    All these updates are valid and the library is successfully updated. The library edit page is displayed with the updates. Any active integrations using the multiply function must be reactivated.



    An example of an invalid Javascript file that would not be successfully uploaded is if the multiply function included a parameter definition that changed (for example, param2 to param3).

    function add ( param1, param2 ) {
         var retValue = param1 + param2; 
         return retValue;
    }
    function multiply ( param1, param3 ) {
         var retValue = param1 * param2 * 2; 
         return retValue;
    }
    function divide ( param1, param3 ) {
         var retValue = param1 / param2; 
         return retValue;
    }

Use Library Functions in Orchestrated Integrations

You can add library functions to orchestrated integrations.

After you create and edit your library functions, they are available from the Actions palette orchestration palette or the Plus icon icon inside an integration. See Add a JavaScript Action.