Feb 02, 2021 05:49 AM
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?
Solved! Go to Solution.
Feb 02, 2021 06:05 AM
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.
Feb 02, 2021 06:05 AM
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.
Feb 02, 2021 07:42 AM
Thanks. That’s working for me now. Much appreciated.