Is there any more documentation on the NewRecord type taken by the TableOperations create() method? I’m trying to add a new row from a button in a widget like this

          let seenTable = grist.getTable("Seen");
                  "Asset": assetRowId,
                  "Date": new Date().toISOString()
          ]).then(function(record) {
          }, function(error) {

The call succeeds but it creates an empty row instead of populating it with the field values I supplied, I guessed at the syntax and it doesn’t seem to work. The Asset column is a reference to another table, the “Date” column is a standard date data column.

Mark Daniel

Here is the source code of the type:

export interface NewRecord {
  fields?: { [coldId: string]: CellValue }; // fields is optional, user can create blank records

which is understandably not helpful for type checking lol. We should probably switch on ‘strict’ type checking to throw an error for unexpected fields like Asset.

Point is, you can use create({fields: {Asset: ...}}).

Thanks for you help. That fixed the problem.

My next problem is with TableOperations.destroy if I pass a single row id, I’m finding that it always returns an error even though it succeeds.

I find that in withRecords it fails on the last line

recordsOrRecord is not an array so it tries to return result[0] but result is null and you get

TypeError: Cannot read properties of null (reading '0')
    at withRecords (TableOperationsImpl.js:125:60)

I don’t know if this function should check for null or maybe the BulkDeleteRecords op shouldn’t be returning null? There is a workaround by making sure you pass an array to destroy() but the documentation does claim you can do either.


Thank you for reporting this bug, I’ve filed it for fixing!