Skip to content

Instantly share code, notes, and snippets.

@sota1235
Last active February 28, 2018 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sota1235/1efe9900074a26e8a927c3a31857eb51 to your computer and use it in GitHub Desktop.
Save sota1235/1efe9900074a26e8a927c3a31857eb51 to your computer and use it in GitHub Desktop.
// Please pass `names` and `foods` from Zapier
// If you want to filter by food name, plz pass `specificFood` from Zapier
const names = inputData.names;
const foods = inputData.foods;
const specificFood = inputData.specificFood;
const delimitor = ','; // If you want to change delimiter, fix this line
const nameList = names.split(delimitor);
const foodList = names.split(delimitor);
let outputText = 'Name\tFood Restriction'; // Headline
for (var i = 0; i < nameList.length; i++) {
const name = nameList[i];
const food = foodList[i];
// If name is empty, stop processing
if (name === '') {
break;
}
// Filter by specific food name
if (specificFood && food !== specificFood) {
continue;
}
outputText = outputText + "\n" + `${nameList[i]}\t${foodList[i]}`; // Row
}
// You can get value named `listText` on Zapier
output = [{
listText: outputText,
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment