Skip to main content

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!

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(listo0])
output.set('sentence', listt0]);
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!


Reply