I have a PeopleEditor control with MultiSelect="false" on a workflow initiation form. If enter 2 names, they both resolve... the workflow just truncates it and keeps only the first entity. I want to keep the workflow from starting if there's more than one name. Everything I've tried to get a count of the entities returns 1. How do I find out how many entities the user has entered?


<SharePoint:PeopleEditor ID="pplPicker" runat="server" AllowEmpty="false" ValidatorEnabled="true" OnValueChangedClientScript="" AllowTypeIn="true" MultiSelect="false" Width="200px"></SharePoint:PeopleEditor>


SPWeb web = SPContext.Current.Web;

string users = "";
ArrayList arrUsers = this.pplPicker.ResolvedEntities;

foreach (PickerEntity user in arrUsers)
    SPUser webUser = web.EnsureUser(user.Key);
    users += webUser.ID.ToString() + ";#" + webUser.Name + ";#";

I've tried:

int i = this.pplPicker.ResolvedEntities.Count;

int i = this.pplPicker.Entities.Count;

int i = this.pplPicker.Accounts.Count;

  • I think I had done this in javascript. You can get the element and see its "value" property. Somewhere down in the properties you will get an array of resolved users. So option (A) use a bit of javascript probably with a hidden field, (B) find out a similar method in c# :) – Nisarg Jun 11 '16 at 4:13
SPUser singleUser = new SPFieldUserValue(item.Web, item["Single User"] as string).User;    
SPUser[] multipleUsers = ((SPFieldUserValueCollection)item["MultipleUsers"]).Cast<SPFieldUserValue>().Select(f => f.User);

I'm not sure why one user is stored as a string, but multiple users are stored as a specific object; it may also not be consistent in this so you might have to debug a bit and see what the type in your field is.

Once you have these SPUsers, you can populate your PeopleEditor control

using the account names as follows (quite long-winded):

ArrayList entityArrayList = new ArrayList();
foreach(SPUser user in multipleUsers) // or just once for a single user
    PickerEntity entity = new PickerEntity;
    entity.Key = user.LoginName;
    entity = peMyPeople.ValidateEntity(entity);

If you want to check any error messages that the control generates for you (if the user input is incorrect), you need to have done this switchout already:

var csa = usrBankSponsor.CommaSeparatedAccounts;
csa = usrOtherBankParties.CommaSeparatedAccounts;
//ErrorMessage is incorrect if you haven't done the above
if (!String.IsNullOrEmpty(usrBankSponsor.ErrorMessage))


If you want to get the collection of users from PeopleEditor than please try below code.

//get the collection of users from people editor  

SPFieldUserValueCollection srvcRepCol = new SPFieldUserValueCollection();

int index = 0;

for (index = 0; index <= this.peopleEdControl.ResolvedEntities.Count - 1; ++index)


      PickerEntity objEntity = (PickerEntity)this.peopleEdControl.ResolvedEntities[index];

     srvcRepCol.Add(new SPFieldUserValue(srvcWeb, Convert.ToInt32(objEntity.EntityData["SPUserID"]), objEntity.Key));


//Assign the users to list item column

item["Customers"] = srvcRepCol;

//Set the value of  users to people editor

if (item["Customers"] != null))


    string users = string.Empty;

    //To get the value from sharepoint list item and storing it in a  SPFieldUserValueCollection.

    SPFieldUserValueCollection userCol = new SPFieldUserValueCollection(web, item["Customers"].ToString());

    foreach (SPFieldUserValue usrItm in userCol)


        users += usrItm.User.ToString() + ",";


    this.peopleEdControl.CommaSeparatedAccounts = users.Remove(users.LastIndexOf(","), 1);

  • this.peopleEdControl.CommaSeparatedAccounts was the piece I needed. Thank you! – Erin L Jun 16 '16 at 18:45
  • Can you please upvote it as well so i will get some credit of it?..Thanks...:) – Hardik Jun 16 '16 at 19:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.