views:

373

answers:

2

How would you filter a list in Sharepoint (WSS 3.0) by a current user's profile property. For example, I have a list with a Department column and I want to filter the list based on the current user's department (which would be a user profile's property).

Any idea's on how to do this?

+1  A: 

Hi Lina, I believe this is a repeated question filter a sharepoint list.

Anyway here you have mijn twee centen. Try adding a tasks web part in your page and add a column "Department" to this tasks web part and enter some value, say 'IT'. Then add a UserContextFilter web part to same page. Configure it so that it sends "Department" user profile value to Tasks web part. At this point, when you try to connect usercontextfilter wp to tasks wp, you won't be able to see "Department" in drop down list. Beacuse this drop down list values are populated based on of tasks web part.

Thanks for the quick answer.
Lina Al Dana
Greg's answer is the more appropiate
+1  A: 

What you'll need to do is first get the user's profile, look up the property, and then use that in your CAML, like so:

UserProfile userProfile = ProfileLoader.GetProfileLoader().GetUserProfile();
string dept = userProfile["department"];    

// SPQuery CAML stuff here
Greg Hurlman
Thx for the reply :)
Lina Al Dana