SAP Open Connectors

Javascript in Formulas

You can choose from several step types that allow you to write your own custom Javascript. The function signature for all JS-related step types looks like:

 * @param  trigger The trigger that started this execution
 * @param  steps   The list of steps that have been executed up until this point for this execution and all of their step execution values
 * @param  info    Metadata about this formula
 * @param  config  The configuration values set on the formula instance (config variables)
 * @param  done    The callback function that you will need to call at the end of your script step
function (trigger, steps, info, config, done) {
  // your Javascript will be executed here

Note the following when writing javascript in formulas:

  • For all scripts, Javascript strict mode is enforced.
  • You can use console.log to log data to the Javascript console to help debug your formula.
  • You can use to send an email notification.
  • ES6 is supported.
  • The function parameters are immutable, meaning they cannot be assigned to directly. To change an object or value passed into the function, first copy it to your own local variable and then make the necessary changes.


  • console.log(str): Log something from the script. This logged value is returned in an array called console, which will be available to see as a step execution value. Takes a string as a parameter.  Unlike the standard Node console.log(str), this version only accepts a single parameter.
  •, subject, body): Send an email notification directly from a Javascript step. to can be a single email or a comma separated list of emails, subject is the subject of the email and body is the body of the email. A value will be returned in an array called notify, which will be available to see as a step execution value. Takes three string parameters. You can reference anything from the context when passing in to, subject or body in the same way you can access these variables elsewhere in the Javascript. For example:, steps.previous-step.subject, steps.previous-step.emailPrefix + '<br>This is the main body.'); 


In order to include each library, you must require each package individually. For example, you would include the axios and lodash libraries accordingly:

const ax = require('axios');
const _ = require('lodash');
  • CE: Our custom library that provides some common functionality. You do not need to require this library because it is available by default.
    • CE.randomString(): Generate a random string (approx. 10 characters long).
    • CE.randomEmail(): Generate a random email address.
    • CE.md5(str): Create an MD5 hash from a string value. Takes a string as a parameter. Returns a string.
    • CE.b64(str): Encode a string in base64. Takes a string as a parameter. Returns a string.
    • CE.decode64(str): Decode a string from base64, using UTF-8 encoding. Takes a string as a parameter. Returns a string.
    • CE.hmac(algo)(enc)(secret, str): HMAC hash a string (str) using the provided secret (secret), algorithm (algo), and encoding (enc). See for more information about the algorithm and encoding parameters.
    • CE.hmac[algo][enc](secret, str): This is a set of convenience functions that allow HMAC hashing using some common algorithms and encodings. For example, CE.hmacSha1Hex(secret, str) will create an HMAC SHA1 hash of the provided string, using the provided secret, and return a hex string. You can replace algo and enc with the following values: algo: Sha1, Sha256, Md5 enc: Hex, Base64
Note: While Node global URL Origin is supported, the module is not maintained by the platform.
  • Lodash: It is possible to use the library modules, as well, such as lodash/fp.
    "lodash": "4.17.20"
  • Axios
    "axios": "0.19.0"
  • Jmespath
    "jmespath": "0.15.0"
  • Moment
    "moment": "2.24.0"
  • Moment Timezone
    "moment-timezone": "0.5.32"
  • Request
    "request": "2.88.2"

  • Request promise
    "request-promise": "4.2.6"

  • Buffer

  • Querystring

  • xhr2
    "xhr2": "0.2.0"