I needed to query an SPList by a User column. I wanted to query the list by account (DOMAINUser) and check that that user existed. Essentially, I’m validating the input of a PeopleEditor control against users in the SPList. Unfortunately, this didn’t look possible – examining my list items through the object model I seemed to get back a value like a lookup field – that is [number;#value]. For example:
Not very useful – accounts are unique, but John Smith’s aren’t. I was beginning to feel a bit frantic about not being able to do this sort of query when I found this very useful post by Karthikeyan Kasiviswanathan. The short of it – you have to set the column up to display the account if you want to query by the account.
Sort of makes sense – but is a bit weird too. I mean, isn’t the account the unique bit? Shouldn’t I always be able to query by that? Still, this should work for me.