Dec 03, 2020 07:03 AM
Hello,
I use this script for move record from table 1 to table 2, All data is moved except data of type dropdown list (Ville). I show this error: Can’t create records: invalid cell value for field ‘Ville’.
Could not find a choice with that ID or name
let table1 = base.getTable("DATA");
let table2 = base.getTable("Con");
let result = await table1.selectRecordsAsync();
for (let record of result.records) {
if (record.getCellValue("Prét")) {
await table2.createRecordsAsync([
{
fields: {
'ID': record.getCellValue("ID"),
'Source': record.getCellValue("Source"),
'Agent': record.getCellValue("Agent"),
'Nom complet': record.getCellValue("Nom complet"),
'Téléphone': record.getCellValue("Téléphone"),
'Ville': record.getCellValue("Ville"),
'Prét': record.getCellValue("Prét")
},
}
]);
await table1.deleteRecordAsync(record.id);
}
}
[details="Summary"]
This text will be hidden
Solved! Go to Solution.
Dec 04, 2020 07:57 AM
The read format and the write formats for single-select values are not the same. Plus, since they re in different tables, the choices will have different ids, even if they have the same name.
Try this.
'Ville': {name: record.getCellValueAsString("Ville")},
Dec 03, 2020 07:08 AM
Yep - that’s expected when you try to create a value in an option list field where such option has not been defined as an acceptable value.
Dec 03, 2020 07:36 AM
Can you give me an alternative solution
Dec 03, 2020 08:10 AM
Before we go down that path, have you verified that my hunch is correct by adding the options to the target table and running the code?
Dec 03, 2020 08:13 AM
Yes, I added the options to the target table, But the same error appears.
Dec 03, 2020 08:15 AM
Then we haven’t assessed the cause, and therefore there is no point to recommending an alternative approach. :winking_face:
Something else in your code is at issue.
Dec 03, 2020 08:19 AM
Is there another solution to moving the records from table 1 to another table?
And thanks in advance :blush:
Dec 03, 2020 08:31 AM
Yes, never do that. :winking_face:
Seriously, I am not the guy to ask about making copies of data because I believe it is generally a very bad idea. There are exceptions to this general philosophy that I have but they are very exceptional cases.
The more effective way to create different views of data is to perform logical extensions of the same data - ergo, nothing needs to be replicated; it only needs to be reshaped to fit specific needs. Airtable provides Views for this.
Dec 03, 2020 08:40 AM
Thank you very much for your time, I think this will help me.
Dec 04, 2020 07:57 AM
The read format and the write formats for single-select values are not the same. Plus, since they re in different tables, the choices will have different ids, even if they have the same name.
Try this.
'Ville': {name: record.getCellValueAsString("Ville")},