Querying people in items_by_column_values

Hi,

I’m trying to find all the tasks assigned to me via the API. I don’t mind how I do this, alternatives are welcome.

Running a specific query like:

query {
  boards(ids:[417546880]) {
    name
    id
    items(ids: [4414440649]) {
      id
      name
      board {
        name
      }
      column_values (ids: ["people"]) {
				title
        id
        value
      }
    }
  }
}

Returns the expected result:

    "boards": [
      {
        "name": "Bradley's Tasks",
        "id": "417546880",
        "items": [
          {
            "id": "4414440649",
            "name": "test",
            "board": {
              "name": "Bradley's Tasks"
            },
            "column_values": [
              {
                "title": "People",
                "id": "people",
                "value": "{\"changed_at\":\"2023-05-04T00:23:16.999Z\",\"personsAndTeams\":[{\"id\":12015589,\"kind\":\"person\"}]}"
              }
            ]
          }
        ]
      }
    ]

But when I write items_by_column_values query that should match that result, it returns nothing:

query {
  items_by_column_values (board_id: 417546880, column_id: "person", column_value: "{\"personsAndTeams\":[{\"id\":12015589,\"kind\":\"person\"}]}") {
  	id
    name
    board {
      name
    }
    column_values {
    	id,
    	title,
    	value
  	}
  }
}

Result:

"items_by_column_values": [],

I believe this is probably because the items_by_column_values query doesn’t support multiple value responses. I’m assuming this is true based on this thread Find items assigned to a user - #6 by TMNXT-Dev and the more recent Find all board items assigned to a person - #4 by BiancaT

The last post seems to be exactly what I’m asking, but I can’t imagine this behaviour isn’t supported in the API server side?

hi @bradleyfalzon

See also Items by column values and specially this part

The query value should be the person’s name, not an object holding the id as in your example. Furthermore it will only return a value when there is exactly one person assigned in the column.

Thanks @basdebruin I did try that, but didn’t see that specific comment, so I didn’t include that note. I am the only person assigned to it, and I have queried using my name.

Although if we do get this to work, but there’s another person that happens to be assigned, then it’s not quite suitable, so perhaps looping through all items across all boards and checking the column client side really is the only solution.

See this query:

query {
  me {
    id
    name
  }
  
  items_by_column_values (board_id: 417546880, column_id: "person", column_value: "Bradley Falzon") {
  	id
    name
    board {
      name
    }
    column_values {
    	id,
    	title,
    	value
  	}
  }
  
  boards(ids:[417546880]) {
    name
    id
    items(ids: [4414440649]) {
      id
      name
      board {
        name
      }
      column_values (ids: ["people"]) {
				title
        id
        value
      }
    }
  }
}

And the response:

{
  "data": {
    "me": {
      "id": 12015589,
      "name": "Bradley Falzon"
    },
    "items_by_column_values": [],
    "boards": [
      {
        "name": "Bradley's Tasks",
        "id": "417546880",
        "items": [
          {
            "id": "4414440649",
            "name": "test",
            "board": {
              "name": "Bradley's Tasks"
            },
            "column_values": [
              {
                "title": "People",
                "id": "people",
                "value": "{\"changed_at\":\"2023-05-04T00:23:16.999Z\",\"personsAndTeams\":[{\"id\":12015589,\"kind\":\"person\"}]}"
              }
            ]
          }
        ]
      }
    ]
  },
  "account_id": xx
}

Hello @bradleyfalzon,

That is correct.

Something like this should work:

{
  items_by_column_values(
    board_id: 1234567890
    column_id: "person"
    column_value: "Matias Lopez"
  ) {
    id
  }
}

But if another person is assigned to the same item, then it will not work.

In this case, if that is an issue, you should, query for the values of that column for all your items and get the IDs of the items where a specific user is assigned, on your end.

Cheers,
Matias

Thanks @Matias.Monday, our use case can definitely have other people assigned.

As I need to do this across all boards, I’ll track a last updated date, fetch all boards, check their last updated date, and if greater than last updated, then fetch all items and check individual colums.

But definitely plus one if there’s an issue tracking support for this feature.

@bradleyfalzon I will add your vote for this request!