Back EntityEditor.Entities is used

RESP510251

Description

It is not recommended to use the Entities property to get the selected entities, because using this sometimes causes unexpected behavior.

Inappropriate usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public SPPrincipalInfo GetPeoplePickerUser(ControlCollection controlCollection)
{
    SPPrincipalInfo result = null;
 
    foreach (Control control in controlCollection)
    {
        var peopleEditor = control as PeopleEditor;
        if (peopleEditor != null && peopleEditor.Entities.Count == 1)
        {
            PickerEntity pickerEntity = (PickerEntity)peopleEditor.Entities[0];
            // get principal info code here ...
            return result;
        }
        if (control.HasControls())
        {
            result = GetPeoplePickerUser(control.Controls);
        }
    }
 
    return result;
}

Resolution

It’s much more reliable to use ResolvedEntities instead.

Links

Last updated: 1/9/2016
Comments
Login to leave a comment.