What format should the defaultSelectedUsers be for the pnp PeoplePicker?

%3CLINGO-SUB%20id%3D%22lingo-sub-1758240%22%20slang%3D%22en-US%22%3EWhat%20format%20should%20the%20defaultSelectedUsers%20be%20for%20the%20pnp%20PeoplePicker%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1758240%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20struggling%20to%20populate%20the%20people%20picker%20here%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%20%20%20%3CPEOPLEPICKER%20context%3D%22%7Bthis.props.context%7D%22%20personselectionlimit%3D%22%7B3%7D%22%20groupname%3D%22%7B''%7D%22%3E%3C%2FPEOPLEPICKER%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20trying%20to%20populate%20it%20with%20the%20items%20retrieved%20from%20an%20SP%20list.%20As%20you%20can%20see%20it%20is%20a%20multi-person%20PP%20which%20accepts%203.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20component%20scope%20variable%20that%20I%20believe%20is%20populated%20correctly%20with%20all%20users%2C%20this%20logs%20as%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E(3)%20%5B%22user03%40domain.com%22%2C%20%22user02%40domain.com%22%2C%20%22user01%40domain.com%22%5D%0A0%3A%20%22user02%40domain.com%22%0A1%3A%20%22user01%40domain.com%22%0A2%3A%20%22user02%40domain.com%22%0Alength%3A%203%0A__proto__%3A%20Array(0)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20if%20I%20add%20the%20panellists%5B%5D%20to%20the%20defaultSelectedUsers%2C%20it%20doesn't%20display%20anything%20on%20retrieval.%20I%20the%20formatting%20wrong%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%2C%3C%2FP%3E%3CP%3ET%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1758240%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EReact%20JS%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESPFx%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Contributor

I'm struggling to populate the people picker here:

 

   <PeoplePicker
      context={this.props.context}
       personSelectionLimit={3}
       groupName={''} // Leave this blank in case you want to filter from all users
       showtooltip={false}
       isRequired={false}
       disabled={false}
       selectedItems={this._getPanellistsPickerItems}//This is the 'onChange'
       showHiddenInUI={false}
         defaultSelectedUsers={panellists ? panellists : []}
       principalTypes={[PrincipalType.User]}
       resolveDelay={1000}
       ensureUser={true}
      />

 

I'm trying to populate it with the items retrieved from an SP list. As you can see it is a multi-person PP which accepts 3.

 

I have a component scope variable that I believe is populated correctly with all users, this logs as:

 

(3) ["user03@domain.com", "user02@domain.com", "user01@domain.com"]
0: "user02@domain.com"
1: "user01@domain.com"
2: "user02@domain.com"
length: 3
__proto__: Array(0)

 

But if I add the panellists[] to the defaultSelectedUsers, it doesn't display anything on retrieval. I the formatting wrong?

 

Regards,

T

1 Reply

This seems to have worked, but I need to test it thoroughly, if anyone can see any probs with it please let me know:

public compilePanellists = () => {
    //@ts-ignore
    panellists.flat();
   this.setState({
     Panellists: panellists
   }, () => {
    console.log(this.state.Panellists);
   });
  
  }