Update "Choice List" from the plugin API

I try to update a choice list with the plugin API (custom widget).

My Choice list is called “Position” with elements from “1” … “81”.
I try to update the list like so (and various other tries i do not show here…):

await grist.selectedTable.updateRecords({"Position": ["1", "2"]},[1])

I expect to see now two elements in the choice list 1 and 2.
But what happens instead is i just see “1” but in red, so i guess its not a choice list value.


Any idea how to update a choice list with the plugin api?
Another question, where is the plugin api documented? I do not find any documentation about the updateRecords but i see (at least some) documentation about the update endpoint, unfortunately i cannot get update to do anything at all…

Ok after a few hours i got it working but this is a little strange:

await grist.getTable().updateRecords({"Position": [{"1":"the value is useless??", "2": ""}]},[1])


Hi @enthus1ast,

Can you try this code:

    id: 1,
    fields: {
      A: ["L", "1", "2"]

In the API, Grist expects encoded JSON values so it can distinguish between regular lists and other objects, hence the “L” value at the beginning. Here is some documentation about the structure used in the API