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 9-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 9-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.