Loading...

Monday, September 19, 2011

'value does not fall in expected range' When assigning SPUser to ListItem


If you try to assign,
ListItem["UserField"]=SPContext.Web.CurrentUser
And you get th Error  " value does not fall in expected range"
Cause:  ListItem is in different Sitecollection
So Directly You can not assign current user.
Resolution:
SPUser differntSiteCollectionUser = differentWeb.SiteUsers.GetByEmail(currentUserMailId);-->GetmailID with SPFieldUserValue

No comments: