☁️️ Quickstart: Workflows - Run code

Starter examples for using Run Code in workflows

With Run Code you can run your own JavaScript code within a Harbour workflow
(TLDR- jump to the example code)

This can be quite useful for:

  • Pulling data in from a third-party systems (e.g., a list of available cost centers)
  • Running your own custom calculations (e.g., determine pricing tier based on inputs)
  • Sending data into a third-party system (e.g., your in-house CMS or project tracker)
Technical notes:
  • Full support for modern JavaScript features (ES 2024+) ✅️
  • Each run can take up to 1 minute and up to 500MB of memory 👌️🏎️️
  • We support both sync and async functions, third-party data requests, and third-party module importing (*see examples below) 🕸️️
  • Your JavaScript can both access available inputs from upstream action blocks (e.g., signer e-mail from an upstream Start agreement) and send results into downstream action blocks 🏈️
  • JavaScript errors are captured and sent to anyone in the Notifications section of the Workflow Settings ⚾🧤

Starter code samples:

//Hello world - basic example
function main(){
return "Hello world~!";
}
//Hello world - basic example, with an upstream input value
function main(inputs){
return "Hello " + inputs.signer1_name + "~!";
}
//Email extraction example - returning multiple values, useable in downstream actions
function main(inputs){
const email = inputs.signer1_email; //e.g., "ada@lovelace.com"
const username_value = email.split("@")[0];
const domain_name_value = email.split("@")[1];
return {"username":username_value, "domain_name":domain_name_value};
}
//Get data example - async function with third-party data
async function main(inputs){
const r = await fetch("https://api.github.com/repositories/5906854/pulls/37/comments");
const json = await r.json();
return "Hello " + json[0].user.login + "~!";
}
//Import module example (Lodash) - async function with imported code and emoji
import * as _ from "https://unpkg.com/lodash-es@4.17.21/lodash.js";
async function main(inputs){
return _.startCase("🦄 hello universe~!");
}