'How can I override ClientPeoplePicker js functions in Sharepoint 2016 On Premise? So I can initialize it with a group

I wanted to override default functionality of the People Picker so that when it is initialized People from a certain GroupID are shown. We have to use out of the box functionality with minimum customizations.

I have tried overriding the whole script, it works. But this is something that I don't want to do. I need to override only a specific function named SPClientPeoplePicker.

function SPClientPeoplePicker(controlProps) {
    this.TopLevelElementId = controlProps.TopLevelElementId;
    this.EditorElementId = controlProps.EditorElementId;
    this.AutoFillElementId = controlProps.AutoFillElementId;
    .
    .
    .
    if (typeof controlProps.SharePointGroupID != "undefined")
        this.SharePointGroupID = DYNAMIC;
   
} ``` 



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source