Possible to get the value of the Column Label?

Is there a programmatic way via formulas to get the label of a given column?

For example, suppose I have a field with a label of “Is Valid”. The internal name of this would end up being Is_Valid. In code, I would like to have a property on the column such as TableName.Is_Valid.label.

It would be equivalent in what the docs/{docId}/tables/{tableId}/columns API endpoint returns for the column in the fields.label property:

{
  "columns": [
    {
      "id": "Is_Valid_",
      "fields": {
        "colRef": 686,
        "parentId": 78,
        "parentPos": 657,
        "type": "Bool",
        "widgetOptions": "",
        "isFormula": false,
        "formula": "",
        "label": "Is Valid?",     <-------
        "description": "",
        ...
      }
    },
    ...
  ]
}

In the meantime, I thought about just taking the internal column name and replacing underscores (_) with spaces… but spaces are not the only things that get replaced with underscores when the internal column name is created. Like in the API response snippet above, a label of “Is Valid?” would become Is_Valid_, so converting the other way would not bring my question mark back.

If this is not possible, consider this a feature request. :slight_smile:

Thank you.

Hi! This is not yet possible in a supported way. But it is possible by reaching into the internals.

table.table._engine.docmodel.get_column_rec("TableName", "Is_Valid").label

Similarly to the answer in https://community.getgrist.com/t/column-name-in-formula/2179/2 about getting the current column, the downside is that this is not public interface and there is no guarantee it will continue working in future versions.

Understood, thank you. This would be a great addition in the officially supported feature set.

T