i have a list that have a user/group column that i want to filter by (the column name is: USERS). how do i get only the items in the list where the current user exists in the USERS column?
If it is simply a customized view, look at a Tasks list and the My Items view for reference.
You should be able to go the the Filter section in the view and have a filter that has "is equal to" "[Me]". However, it sounds like this is a multi-valued field so maybe you can get away with "contains" "[Me]".
Another considerations is looking into Audiences if you have MOSS. The Content Query Web Part is capable of filtering list items based on the audience.
Hi Kisin,
I do have a similar requirement, I have a column with users or groups (multiple users / groups mixed together) . I want to apply filter. Did you get the answer ? This helps me a lot. I have to implement this in WSS ..
Thanks in advance Jagkon
jagkon, i used this code to go over the column and check each item:
if (item["users"] != null)
{
//get USERS field for item
SPFieldUserValueCollection fieldUserValueCollection = new SPFieldUserValueCollection(web, item["users"].ToString());
//go over the users/groups collection
foreach (SPFieldUserValue fieldUserValue in fieldUserValueCollection)
{
if (fieldUserValue.User == null) //group
{
if (web.SiteGroups.GetByID(fieldUserValue.LookupId).ContainsCurrentUser)
{
bolItemGood = true;
break;
}
}
else //user
{
if (fieldUserValue.User.IsDomainGroup) //domain group
{
if (web.IsCurrentUserMemberOfGroup(fieldUserValue.LookupId))
{
bolItemGood = true;
break;
}
}
else //sp user
{
if (fieldUserValue.User.LoginName == Context.User.Identity.Name)
{
bolItemGood = true;
break;
}
}
}
}
}