Hi All,
In a following example will demonstrate about how to use People Picker values in SharePoint.
Reading From People Picker Control:
SPFieldUserValueCollection PeopleCollection =new SPFieldUserValueCollection();
if (pplPickerID.ResolvedEntities.Count > 0)
{
foreach (PickerEntity pkrTlEnty in pplPickerID.ResolvedEntities)
{
SPUser spUser = web.EnsureUser(pkrTlEnty.Key);
PeopleCollection.Add(new SPFieldUserValue(web, spUser.ID, spUser.LoginName));
}
if (PeopleCollection != null)
{
sList["XXXX"] = PeopleCollection;
}
}
Bind Values to People Picker Control:
In a following example will demonstrate about how to use People Picker values in SharePoint.
Reading From People Picker Control:
SPFieldUserValueCollection PeopleCollection =new SPFieldUserValueCollection();
if (pplPickerID.ResolvedEntities.Count > 0)
{
foreach (PickerEntity pkrTlEnty in pplPickerID.ResolvedEntities)
{
SPUser spUser = web.EnsureUser(pkrTlEnty.Key);
PeopleCollection.Add(new SPFieldUserValue(web, spUser.ID, spUser.LoginName));
}
if (PeopleCollection != null)
{
sList["XXXX"] = PeopleCollection;
}
}
Bind Values to People Picker Control:
SPFieldUserValueCollection oPeopleCollection = ProDetails["ColumnName"] as SPFieldUserValueCollection;
if (oProjectManagerColl != null)
{
string managers = string.Empty;
foreach (SPFieldUserValue pplItem in oPeopleCollection)
{
managers += Convert.ToString(pplItem.User.LoginName) + ",";
}
pplPickerID.CommaSeparatedAccounts = managers.Remove(managers.LastIndexOf(","), 1);
}
Reading People User Value from the List Item:
1.
SPFieldUser field = risksItem.Fields.GetField("ColumnName") as SPFieldUser;
if (field != null)
{
SPFieldUserValue spfldrUserValue = field.GetFieldValue(Convert.ToString(risksItem["ColumnName"])) as SPFieldUserValue;
if (spfldrUserValue != null)
{
// place your code here
}
}
2.
SPFieldUserValueCollection UserCollection = (SPFieldUserValueCollection)ofield.GetFieldValue(oTaskItem["Assigned To"].ToString());
foreach (SPFieldUserValue user in UserCollection)
{
SPUser spAssignedUser = user.User;
}
Related Post
People Picker
SharePoint
- Build Automation (CICD) of WebJob in SharePoint Online
- List view render using JSLink with Fabric UI
- Delete Quick Links using Powershell
- SharePoint Interview Questions and Answers..
- Issues:SharePoint Foundation 2013 Prerequisites installation(off line) on Windows Server2012 R2
- SharePoint Column Field Types
- Alternate to InfoPath Forms in SharePoint
- Get the Items inside the Folder in document Library in SharePoint 2013 using REST API
- SharePoint 2016 [Beta] Release Date
- SharePoint Modal Dailoge to Open Page
- What is Look up Column and how to use in SharePoint 2010,2013
- People Picker Check User Entry and Resolve
- How to Get User Data from AD (Active Directory) in SharePoint Using C#
- History of SHAREpoINt
- How to Create Application Page in SharePoint using Visual Studio 2010,2013
- Retrieve Site Features in SharePoint
- Weather Webpart by using Yahoo Service in Share Point
- Activate Telnet Client in Windows Server
- Navigate to another Page After Clicking on JavaScript Alert
- How to read List Item Version Collection Programmatically
- How to get Worker Process from Command Prompt
- How to Use DataTable.js in SharePoint webpart
- Adding New Link to PromotedActions Delegate Control in SharePoint 2013
- How to Deploy Master Page in Share Point
- Get Role Definition in SharePoint
0 comments:
Post a Comment