Skip to main content

I am trying to write multiple new records to a table. The docs suggest doing this like so:


table.createRecordsAsync([{'My field name': '1'}, {'My field name': '2'}, {'My field name': '3'}]);

In my code I have the following test:


table.createRecordsAsync([{ 'Name': "Dave"}, { 'Name': "Sam"}])

But I get the below error:


invalid record format. please define field mappings using 'fields' key for each record definition object

As a check, I also attempted to write a single row, like so:


table.createRecordAsync({ 'Name': "Dave"})

And this worked fine.


I also attempted this:


table.createRecordsAsync([{ 'Name': "Dave"}])

And I got the same error as before. So it seems to be something about the createRecordsAsync method and passing an array.


Any ideas?

Hey @Stevan_Popovic! This looks like a mistake in the guide you linked. The API docs for table.createRecordsAsync have the correct syntax. Instead of table.createRecordsAsync([{ 'Name': "Dave"}]), you need to wrap you cell values in a fields object, like this: table.createRecordsAsync([{ fields: {'Name': "Dave"} }])


Or with several records:


table.createRecordsAsync([
{ fields: { 'Name': "Dave" } },
{ fields: { 'Name': "Sam" } },
]);

Thanks for pointing this out! We’ll get the getting started doc fixed soon.


Hey @Stevan_Popovic! This looks like a mistake in the guide you linked. The API docs for table.createRecordsAsync have the correct syntax. Instead of table.createRecordsAsync([{ 'Name': "Dave"}]), you need to wrap you cell values in a fields object, like this: table.createRecordsAsync([{ fields: {'Name': "Dave"} }])


Or with several records:


table.createRecordsAsync([
{ fields: { 'Name': "Dave" } },
{ fields: { 'Name': "Sam" } },
]);

Thanks for pointing this out! We’ll get the getting started doc fixed soon.


Thanks. That’s working for me now. Much appreciated.


Reply