
Comment Post Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 06, 2020 04:26 PM
I’m trying to set up an automated email that fills in the contents of a multiple select field. Is there a way to insert the multiple select field in something like a plain english list?
For example, I have a multiple select that has [Sam; Suzy; Pete]. I would like to insert the sentence “Sam, Suzy, and Pete” into my email.
Thanks!
1 Reply 1

Comment Post Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 14, 2020 12:08 PM
Here is an implementation in the Scripting App:
// 🧲
const list = input.config().any_list
//console.log(list)
// 🧞♂️
function makeSentence(list) {
switch(list.length){
case 1:
//console.log(list[0])
output.set('sentence', list[0]);
break;
case 2:
let two = list
.join(' and ')
//console.log(two)
output.set('sentence', two);
break;
default :
let more = list.length ? list
.slice(0, list.length - 1)
.join(', ')
+ ', and ' + list.slice(-1)
: console.error('The list was totally empty!')
//console.log(more)
output.set('sentence', more)
}
}
// ▶
makeSentence(list)
// someday this will be the answer:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat
//
Let me know if that works for you as it is something that I am going to need very shortly in my own base. Thanks!
