Feb 12, 2021 07:30 AM
Hi,
I’ve a simple code to move checked record from table to other table:
let foraccept = base.getTable(“For Accept”);
let plugins = base.getTable(“Plugins”);
let result = await foraccept.selectRecordsAsync();
for (let record of result.records) {
if (record.getCellValue(“Accepted”)) {
await plugins.createRecordsAsync([
{
fields: {
‘Name’: record.getCellValue(“Name”),
‘Website’: record.getCellValue(“Website”),
‘Type’: record.getCellValue(“Type”),
},
}
]);
await foraccept.deleteRecordAsync(record.id);
}
}
My problem is: How i get values from single or multiple select? (Field “Type”) → ‘Type’: record.getCellValue(“Type”).
It is possible?
Mar 11, 2021 10:04 AM
Hey @Mariusz_Jankowski :winking_face:
Try this:
let foraccept = base.getTable("For Accept");
let plugins = base.getTable("Plugins");
let result = await foraccept.selectRecordsAsync();
let typeTypedField = foraccept.getField('Type')
const typeTypedFieldOptions = typeTypedField !== null ? typeTypedField.options.choices : [];
for (let record of result.records) {
let matchTypeField = record.getCellValue('Type');
let matchType = matchTypeField ? matchTypeField.name : '';
let newValue1 = typeTypedFieldOptions.find(o => o.name === matchType);
if (record.getCellValue("Accepted")) {
await plugins.createRecordsAsync([
{
fields: {
"Name": record.getCellValue("Name"),
"Website": record.getCellValue("Website"),
"Type": {name : newValue1.name}
},
}
]);
await foraccept.deleteRecordAsync(record.id);
}
}
Mar 13, 2021 12:17 AM
everything works, thank you;)