API: return value instead of id for reference columns

Is there a quick way to get the value of a cell in a Reference column, instead of its id?

Currently, I need to add a function each time to do a lookup in the reference table by id to get the value.

Would be good if it would return the value instead by default, or simply by adding .value (or similar) to it.

Even better would be to be able to return the value from another cell for that record with the same approach.

So for example, if my reference table Country (with list of countries) includes:
id
name
code

and my Contact table has a reference to it,

contact.country would return the id (current/default)
contact.country.name would return country name (display name)
contact.country.code would return country code

The value in a Reference column actually is a row ID. What you typically see when looking at the column is actually a special hidden column called something like gristHelper_Display with a simple formula like $country.name. We’ve considered an option to retrieve columns like that in the /records API but that doesn’t feel like a great solution for your problem.

What you can do is just make a regular column with the formula $country.name (and/or $country.code) and retrieve that column in the API. You can hide the column in all your widgets so it doesn’t clutter them and it will still be available in the API.

I also wanted to mention that the API endpoint that gets contents of a table as a CSV file does return the display value of reference columns.

1 Like