ReferenceList ("r") vs List ("L") when creating records via n8n

Hi everyone,

I’m currently working on a project that connects n8n with Grist and involves several related tables.

I have two tables, for example:

  • Offres
  • motCles

In the Offres table, I have a Reference List column that can reference multiple records from the motCles table.

When creating a new Offres record from n8n, I initially tried to populate this Reference List using:

["r", id1, id2]

id1 and id2 are Numbers.
According to the Grist documentation, “r” corresponds to ReferenceList:

ReferenceList = “r”

However, this did not work when sending the data through n8n.

What did work was:

["L", id1, id2]

Interestingly, “L” is documented as:

List = “L”

and appears to be intended for regular Lists rather than Reference Lists.

So my questions are:

  1. Is [“L”, id1, id2] actually the correct format to use when setting a Reference List value through the API?
  2. Or am I using the API incorrectly and [“r”, id1, id2] should work?
  3. If [“L”, id1, id2] is indeed the expected format, could the documentation be clarified to explain this distinction?

For now, using ["L", id1, id2] solves my problem, but I’m wondering whether this is expected behavior or if I simply misunderstood something in the documentation.

Thanks!

Hello @Vincent_Ferreira ,

["L", id1, id2] is correct — that’s the expected format for sending list values to Grist. "L" is the encoding Grist uses for storage and input of every list-valued column: ChoiceList, Attachments, and Reference List.

["r", tableId, [rowIds]] is an output format. It shows up when Grist re-encodes values to be self-describing — e.g. values in an Any column, or in results from GET /records?cellFormat=typed, or the “typed” option of the custom widget API. But it’s not accepted as a format in which to send values to Grist.

By the way, a useful alternative if you have keyword text rather than row IDs, is to let Grist do the lookup, using the lowercase l (lookup) shape: ["l", ["keyword A", "keyword B"]] (looking up on whichever column is configured as the “Show Column” for that Reference List), or ["l", ["keyword A", "keyword B", {"column": "Name"}] (to look up by column Name).

A good page that covers data formats is grist-core/documentation/grist-data-format.md at main · gristlabs/grist-core · GitHub — but even that one isn’t clear about which format to use for inputs. That would be good to improve.