Filter User Columns by Account

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:

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.

Filter User Columns by Account

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.