What is the accepted solution for querying/updating Column Name instead of ID?

I’ve seen a number of posts asking the same thing, but want to know what is the definitive way of querying/updating columns across multiple boards that have the same COLUMN NAME, but because of changing circumstances during setup have different Column IDs? e.g. Column ‘My Column Name’ in board 1 had ColumnID ‘text_1’, but in board2 has ColumnID ‘text2’.

We cannot rename ColumnID after creation.

I cannot seem to pull ColumnName using the API.

e.g.

function fetchMondayData(boardId, limit) {
  const query = `{
    boards(ids: ${boardId}) {
      items_page(limit: ${limit}) {
        items {
          id
          column_values {
            title
            text
          }
        }
      }
    }
  }`;

the API always returns an error that ‘title’ doesn’t exist.

I’m obviously not alone in wanting to create a function that queries and updates columns in multiple boards. So what is the solution if we can’t rely on ColumnID?

I look forward to anyone’s help.

Many thanks.

{
   boards {
      columns {
         id
         title
      }
      items_page(limit: ${limit}) {
        items {
          id
          column_values {
            column {
               id
               title
            }
            id
            text
          }
        }
   }
}

Title is no longer directly part of the column_value, but can be accessed through column on the column_value. You can also get any other fields of a column within that subquery.

The reason for this, is that they don’t have to go to the column object itself for those values unless you explicitly want them with your column value. Or you can get them directly from the board itself rather than the item as shown. id is obviously on both column and column_value - and the same.

1 Like