
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Mar 22, 2023 11:23 AM
I'd like to create a new table by importing from an excel worksheet. There will be 30+ fields and i want the single select options to be True and False.
When i've tried to add the single select options manually as answers and then convert the field to be single select, it reverses the order. on my survey, i do not want the answers to be False and True, but True and False.
Is there a way to do this without going through and manually changing every single field to single select and re-ordering the options for each one?
thanks!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Mar 23, 2023 03:25 AM - edited ‎Mar 23, 2023 03:28 AM
Hi,
Set table in line 1 and if you need any singleSelect field to skip, put it's name in line 2
I suppose there are 2 options only, without 'empty option', otherwise it will fail to change field options
const selects=base.getTable('Table1').fields.filter(x=>x.type==='singleSelect')
const toChange=selects.filter(x=>!['Exclude example','place fieldnames','to skip'].includes(x.name))
const swap=arr=>({choices:[arr[1],arr[0]]})
const setTF=async f=>await f.updateOptionsAsync(swap(f.options.choices))
let ask=await input.buttonsAsync('To Change: '+toChange.map(x=>x.name).join(),['Yes','No'])
if (ask=='Yes') for (let fld of toChange) await setTF(fld)
