Here in following method first I am creating the SPUser by using EnsureUser method of SPSite and then adding that SPUser in SPListItem of SPList. Then I am fetching that SPUser from the SPListItem.
(In Folloing method codes with comments are self-explainatory)
/// <summary>
/// Working with with column of type [Person OR Group]
/// </summary>
void user()
{
//SPListItem spListItem;
string loginName = "DOMAIN\\USERNAME";
//Assign SPUser in your custom column and
//also its Login name (string) in seperate column
//(for ease in development operation)
spListItem["User"] = oWebsite.EnsureUser(loginName);
spListItem["UserLoginName"] = loginName;
//Fetch SPUser values from SPColumn
SPFieldUserValueCollection values
= (SPFieldUserValueCollection)spListItem["User"];
loginName = values[0].User.LoginName;
}
Note : From UI control point of view, we can use SharePoint's PeoplePicker control to enter and validate SPUser.
My current project requires ability to display choice column value via color or image associated with a choice
ReplyDeleteBut Sharepoint standard packaged misses that control
I am looking for available solutions on market
I came across
http://amazepoint.com/Products/VisualChoiceColumn/Overview.aspx>
Does anybody has experiece using it?