Move record table to other table

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?

Hey @Mariusz_Jankowski :wink:
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);
	}
}

everything works, thank you;)