> Fields that are either a singleLineText or a multilineText.
Hm, I don't know of a way to restrict users to picking from specific field types, so you'd have to do a check when they were actually running the app, and then prevent them from using it if you detected the wrong type of field was selected
I've put something together below that allows for multiple fields and checks whether one of the selected fields is a `singleLineText` type for you to start with
re: only being able to select each field once
If I were you I'd compile all the selected field IDs and check whether there were duplicates I think
let settings = input.config({
title: `Test`,
description: `Test`,
items: [
input.config.table("table", { label: `Table` }),
input.config.field("field", { parentTable: `table`, label: `Field` }),
input.config.field("field2", { parentTable: `table`, label: `Field 2` }),
],
});
let { table, field } = settings;
test()
function test(){
if (field.type != "singleLineText"){
console.log("Field must be single line text")
}
else{
console.log("OK")
}
}
> Fields that are either a singleLineText or a multilineText.
Hm, I don't know of a way to restrict users to picking from specific field types, so you'd have to do a check when they were actually running the app, and then prevent them from using it if you detected the wrong type of field was selected
I've put something together below that allows for multiple fields and checks whether one of the selected fields is a `singleLineText` type for you to start with
re: only being able to select each field once
If I were you I'd compile all the selected field IDs and check whether there were duplicates I think
let settings = input.config({
title: `Test`,
description: `Test`,
items: [
input.config.table("table", { label: `Table` }),
input.config.field("field", { parentTable: `table`, label: `Field` }),
input.config.field("field2", { parentTable: `table`, label: `Field 2` }),
],
});
let { table, field } = settings;
test()
function test(){
if (field.type != "singleLineText"){
console.log("Field must be single line text")
}
else{
console.log("OK")
}
}
Thank you @TheTimeSavingCo. What I'm looking for is something that would actually depend on how many fields there are in the base. So if the table has 20 fields, it should allow to choose all of those fields, however it should work dynamically without knowing how many fields are in the table when writing the script.
Here the piece of code in my program doing exactly what your want,
let tfields=tableOne.fields.map(f=>f.name.toString())
let ask=''; let chosen=[]; tfields.unshift('DONE!');
while (ask!='DONE!') {
ask=tfields.length==1? 'DONE!':await input.buttonsAsync('Choose fields: ', tfields)
chosen.push(tfields.splice(tfields.indexOf(ask),1)[0]);
output.clear; output.text('Chosen fields: '+chosen.join(', '));
output.text('==================')
}
chosen.pop();
except that you need to adjust first line - change table name and add field type filtering, like
.fields.filter(fl=>fl.type.includes('Text')).map(
after that piece, when user select DONE, array 'chosen' contains selected field names
Here the piece of code in my program doing exactly what your want,
let tfields=tableOne.fields.map(f=>f.name.toString())
let ask=''; let chosen=[]; tfields.unshift('DONE!');
while (ask!='DONE!') {
ask=tfields.length==1? 'DONE!':await input.buttonsAsync('Choose fields: ', tfields)
chosen.push(tfields.splice(tfields.indexOf(ask),1)[0]);
output.clear; output.text('Chosen fields: '+chosen.join(', '));
output.text('==================')
}
chosen.pop();
except that you need to adjust first line - change table name and add field type filtering, like
.fields.filter(fl=>fl.type.includes('Text')).map(
after that piece, when user select DONE, array 'chosen' contains selected field names
This is perfect. Thank you!!!