Help

Re: Can't create records: Could not find a choice with that ID or name

Solved
Jump to Solution
3343 1
cancel
Showing results for 
Search instead for 
Did you mean: 
abderrahim_dib
5 - Automation Enthusiast
5 - Automation Enthusiast

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
1 Solution

Accepted Solutions
kuovonne
18 - Pluto
18 - Pluto

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")},

See Solution in Thread

10 Replies 10

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.

Can you give me an alternative solution

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?

Yes, I added the options to the target table, But the same error appears.

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.

abderrahim_dib
5 - Automation Enthusiast
5 - Automation Enthusiast

Is there another solution to moving the records from table 1 to another table?
And thanks in advance :blush:

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.

abderrahim_dib
5 - Automation Enthusiast
5 - Automation Enthusiast

Thank you very much for your time, I think this will help me. Heart

kuovonne
18 - Pluto
18 - Pluto

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")},