none
PeopleEditor UpdateEntities method alternative RRS feed

  • Question

  • Hello all,

    I have on a page more than 5 PeopleEditor controls which are populated through code on page loading event.

    Everything is working fine but it takes too long to validate the entities(more than 30 seconds), and this is not an acceptable solution.

    I tried to just add the users, and not to validate them, but the look is not too good, the user names look like "No matching names".

    Do you know what alternative should I use instead of "UpdateEntities()" and "ValidateEntity()"?

    Thank you,

    Bogdan


    Bogdan

    Monday, March 26, 2012 8:01 AM

Answers

  • Hi Bogdan46,

    You can set the ValidatorEnabled in your coding, then it will be validate in client.

    using (SPWeb web = SPContext.Current.Web)
    {
        this.PeopleEditor1.ValidatorEnabled = true;
        SPUser user = web.CurrentUser;
        PickerEntity entity = new PickerEntity();
        entity.Key = user.LoginName;
        System.Collections.ArrayList entityArrayList = new
        System.Collections.ArrayList();
        entityArrayList.Add(entity);
        PeopleEditor1.UpdateEntities(entityArrayList);
    }

    Thanks,

    Jack

    Wednesday, March 28, 2012 6:40 AM
    Moderator

All replies

  • Hi Bogdan46,

    You can set the ValidatorEnabled in your coding, then it will be validate in client.

    using (SPWeb web = SPContext.Current.Web)
    {
        this.PeopleEditor1.ValidatorEnabled = true;
        SPUser user = web.CurrentUser;
        PickerEntity entity = new PickerEntity();
        entity.Key = user.LoginName;
        System.Collections.ArrayList entityArrayList = new
        System.Collections.ArrayList();
        entityArrayList.Add(entity);
        PeopleEditor1.UpdateEntities(entityArrayList);
    }

    Thanks,

    Jack

    Wednesday, March 28, 2012 6:40 AM
    Moderator
  • Hi,

    We have also written a similar code to get users from saved DB and during page load set them to client people picker control

    However, sometime we are seeing that the ID is not getting resolved as expected and the entire SAML token with user ID gets displayed on the people picker control

    the sample code which adds users to List<Entity>

     PickerEntity entity = new PickerEntity();
                                        PeopleEditor pe = new PeopleEditor();
                                        entity.EntityData["AccountName"] = userProfile.AccountName;//oSPUser.LoginName;
                                        entity.EntityData["SPUserID"] = userProfile.ID;//oSPUser.ID;
                                        entity.EntityData["Email"] = userProfile[PropertyConstants.WorkEmail].Value;//oSPUser.Email;
                                        entity.Key = userProfile.AccountName;
                                        entity.Description = userProfile.AccountName;
                                        entity.DisplayText = userProfile.DisplayName;
                                        entity = pe.ValidateEntity(entity);

                                        if (entity != null)
                                        {
                                            entity.IsResolved = true;
                                            savedEntity.Add(entity);

                                            Logger.LogError(SPCustomCategory.RequestForm.ToString(),
                                               string.Format("Entity object resolved in People editor {0}", userProfile.AccountName));
                                        }
                                        else
                                        {
                                            entity.IsResolved = true;
                                            savedEntity.Add(entity);

                                            Logger.LogError(SPCustomCategory.RequestForm.ToString(),
                                                string.Format("Entity object not resolved in People editor {0}", userProfile.AccountName));
                                        }

                                            

    Thanks & Regards, Soumyadev | Posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, September 9, 2014 11:12 PM
  • The problem was resolved by a fix from custom claims provider s/w

    Thanks & Regards, Soumyadev | Posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, October 1, 2014 1:56 PM
  • I use the following in sp2010:

    PeopleEditor1.Entities.Add(PeopleEditor1.ResolveAccountsByArrKeys(spclaimencodingstringarray));

    for performance  issue you should optimize the resolving of claim providers, such as the performance of AD querying, or limit the EnabledClaimProviders used by your peopleeditor.


    update: set PeopleEditor.ValidateResolvedEntity = false also improve performance by avoiding redundant resolvingl
    • Edited by GuYuming Sunday, July 28, 2019 1:22 AM
    Saturday, July 27, 2019 11:03 PM