Filter User Columns by Account

I needed to query an SPList by a User column. I wanted to query the list by account (DOMAIN\User) 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:

1#;John Smith

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>