How to retrieve specific column by name?

I’m using the below query at the moment which works fine, but I only want the data for two specific columns. I am giving the text/string value (column name) as the column ‘id’, but so far none of my attempts have worked. Here is my current query and hope someone can help:
boards (ids:XXXX) { items { column_values { title text }}}}

Things I tried: thought I could maybe specify the column by providing its title, “Status”, to the title key. Also tried to refer to it by "id: “Status” but this didn’t work. I had that under columns/column_values. Maybe my syntax was wrong, but could be faulty approach too!

I am not sure if retrieving specific column values is possible. What you could do is take all the values and filter out the ones you need . I am using same approach for now. May be someone from Monday could confirm otherwise.

2 Likes

Hey there @Shinny and @vishwajeets

That’s a great question! It is currently not possible to retrieve a specific column by name, or ID, and I would indeed recommend querying all of the board data and then filtering the specific values you need in your application logic instead. I hope that helps. :slight_smile:

EDIT: I stand corrected - please check @mitchell.hudson 's post just below my own that provides a working API query example that can look up column values based on column ID.

-Alex

1 Like

Hi @Shinny and @vishwajeets

@AlexSavchuk, I might be reading the question wrong, but you can actually query based on the column_id. I have attached a sample query below.

{
  boards(ids: XXX) {
    items {
      column_values (ids: ["text", "status"]) {
        title
        text
      }
    }
  }
}

This will return the data for each item in the board, but only the column values that you have requested.

{
  "data": {
    "boards": [
      {
        "items": [
          {
            "column_values": [
              {
                "title": "Status",
                "text": "Done"
              },
              {
                "title": "First Name",
                "text": "Test"
              }
            ]
          },
          {
            "column_values": [
              {
                "title": "Status",
                "text": null
              },
              {
                "title": "First Name",
                "text": ""
              }
            ]
          }
        ]
      }
    ]
  },
}

I only have a few items in this board. You can find the column id’s by using the API, or by enabling the developer tools in monday Labs.

Let me know if I have misunderstood your question.

2 Likes

Indeed, as @mitchell.hudson shows, it is possible to retrieve column data by columnId. This is not possible by column_name. It looks like this is because column names can be changed by the user, where column ids are set by the system and can’t be changed.

1 Like

@mitchell.hudson oh, that makes perfect sense! I am sorry for the misleading answer previously, and I really appreciate your clarification here, especially with a working code example as well.

@basdebruin thank you for siding with Mitchell here :slight_smile:

-Alex

Thanks all! This absolutely solves the case.

1 Like