Do we have alternate to prepopulate the PnP people picker control using security group that doesn't have email assigned

Harsha Vardhan Reddy 0 Reputation points
2023-10-26T13:41:44.3566667+00:00

Do we have alternate to prepopulate the PnP people picker control using security group that doesn't have email assigned

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,300 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,810 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 33,641 Reputation points Microsoft Vendor
    2023-10-30T01:50:24.13+00:00

    Hi @Harsha Vardhan Reddy,

    If you're working with the SharePoint PnP (Patterns and Practices) People Picker control and want to prepopulate it with a security group that doesn't have an email assigned, you can use the Group ID or Group Principal Name (UPN) instead.

    Here's an example of how you can use the Group ID:

    JavaScriptCopy

    var groupID = 123;  
    var peoplePicker = new PnPClientStoragePeoplePicker({}); 
    peoplePicker.SetEnabledState(true); peoplePicker.SetUrlZone(1); peoplePicker.SetParentElement(document.getElementById('peoplePickerDiv')); peoplePicker.SetPrincipalType(1); peoplePicker.SetSearchPrincipalSource(15); peoplePicker.SetEnabledState(true); peoplePicker.AddUserKeys([groupID]);
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.