ℹī¸Formatting arrays correctly

Background

When working with Zapier, adding data to arrays needs some extra JavaScript to convert the data. Zapier calls arrays "Line Items" and formats them like so, [123,456,789] whereas Siteglide API expects a JavaScript formatted array such as, ["123","456","789"]

To convert these two data types, use the screenshots and code below. In this example we are getting a pre-existing user and their Secure Zones, then adding in a new item.

Zapier Setup

let data = inputData.sz.split(','); //Where sz is the name of the input data you picked above
let array = [];

data.forEach(item => array.push(item));
array.push("178375") //The ID of your secure zone

output = {output: JSON.stringify(array)};

The above javascript code and flow can be used for anywhere that you need to add an item to Line Items within Zapier

Last updated