Check if the people picker has a user or a group in sharepoint Programatically
A quick tip to check if the account in the people picker field for an item is a User or a SharePoint group using code.
Code -
SPweb web = SPContext.Current.Web;
SPFieldUserValue _pickerValue = new SPFieldUserValue(web, item["PeoplePickerName"].ToString());
bool isUser = SPUtility.IsLoginValid(site, pickerValue.User.LoginName);
if (isUser)
{
// Its a SharePoint User
}
else
{
// Its a SharePoint Group
}
Code -
SPweb web = SPContext.Current.Web;
SPFieldUserValue _pickerValue = new SPFieldUserValue(web, item["PeoplePickerName"].ToString());
bool isUser = SPUtility.IsLoginValid(site, pickerValue.User.LoginName);
if (isUser)
{
// Its a SharePoint User
}
else
{
// Its a SharePoint Group
}
0 comments:
Post a Comment