From 7e035147960d24ac0308e1c408a5a3597ed18073 Mon Sep 17 00:00:00 2001 From: Mikhail Perlov Date: Sun, 18 Apr 2021 14:43:27 -0400 Subject: [PATCH 1/2] Add files via upload new external script to adds quotes to comma-separated lists --- Scripts/addQuotesToCommaSeparatedList.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Scripts/addQuotesToCommaSeparatedList.js diff --git a/Scripts/addQuotesToCommaSeparatedList.js b/Scripts/addQuotesToCommaSeparatedList.js new file mode 100644 index 0000000..6dff3a1 --- /dev/null +++ b/Scripts/addQuotesToCommaSeparatedList.js @@ -0,0 +1,13 @@ +/** + { + "id": "co.perlovs.Esse.ExternalFunctions.addQuotesToCommaSeparatedList", + "name":"Add quotes to a comma separated list", + "description":"Takes in a comma-separated list and adds single quotes around each item", + "category":"Convert", + "author":"Perlovs", + } +**/ + +function main(input) { + return "'" + input.split(',').map(s => s.trim()).join("','") + "'"; +} \ No newline at end of file From 1f61eeddf9ecd882f02f67f88abceb0c6803e564 Mon Sep 17 00:00:00 2001 From: mishamsk Date: Fri, 30 Apr 2021 22:25:04 -0400 Subject: [PATCH 2/2] fixed name and added empty string check --- Scripts/addQuotesToCommaSeparatedList.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Scripts/addQuotesToCommaSeparatedList.js diff --git a/Scripts/addQuotesToCommaSeparatedList.js b/Scripts/addQuotesToCommaSeparatedList.js new file mode 100644 index 0000000..47b46c4 --- /dev/null +++ b/Scripts/addQuotesToCommaSeparatedList.js @@ -0,0 +1,17 @@ +/** + { + "id": "co.perlovs.Esse.ExternalFunctions.addQuotesToCommaSeparatedList", + "name":"Add Quotes to a Comma Separated List", + "description":"Takes in a comma-separated list and adds single quotes around each item", + "category":"Convert", + "author":"Perlovs", + } +**/ + +function main(input) { + if (input !== '') { + return "'" + input.split(',').map(s => s.trim()).join("','") + "'"; + } + + return input +} \ No newline at end of file