You have person or group field in SharePoint list and you want to programmatically get the user or person. The below code to gets SPUser from User or Group field in the list when multiple choice and Groups are not allowed in the field: //get SPUser SPFieldUser userField = (SPFieldUser)item.Fields.GetField("Users"); SPFieldUserValue userFieldValue = (SPFieldUserValue)userField.GetFieldValue(item["Users"].ToString()); SPUser user = userFieldValue.User; This part of code would help you to get SPUser when multiple choice is allowed and groups are not allowed: //Multiple choices are allowed SPFieldUser userField = (SPFieldUser)item.Fields.GetField("Users"); SPFieldUserValueCollection userFieldValueCollection = (SPFieldUserValueCollection)userField.GetFieldValue(item["Users"].ToString()); foreach (SPFieldUserValue userFieldValue in userFieldValueCollection) { Console.WriteLine(" " + userFieldValue.User.LoginName); } And when group...
Idea, Thought, Opinion, Feedback, Challenges, Experiences on Microsoft platform.
Hi Senthil, You are a champ, dude. I followed the steps which you have mentioned in your blog and it helped me resolve my search. Keep it up mate!!
ReplyDeleteCheers,
Dilip
Thanks. you saved my life.
ReplyDeleteThank you for the blog. Saved me a lot of troubleshooting and searching through menus. Our search service went crazy overnight and I had to wipe the folder out and restart the crawl.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThanks Senthil. This is good solution but in my case we are getting Index Corruption error daily in Prod Env.
ReplyDeleteDo you help us to understand why this is happening daily.