John McAulay
John McAulay

Reputation: 305

mgt-react PeoplePicker defaultSelectedUsers not working as I would expect

I've been writing a React app that relies on the mgt-react components.

The app is basically just an interface to a SharePoint library.

Everything has been working great and the PeoplePicker is working in so much as I can start typing a users name and the drop down works and I can select a person.

However now I'm at the point where I want to create an edit screen. In order to implement this I need to prepopulate the PeoplePicker with the users that were input at insert time.

I can't seem to get the "defaultSelectedUsers" property to work.

I've pared things down to simply hardcoding a users email address and it still doesn't work.

Here is my code for the component (email address changed for privacy reasons):

<PeoplePicker defaultSelectedUsers={['[email protected]']} selectionMode="single" selectionChanged={handleSelectionChanged}></PeoplePicker>

No matter what I do it is not prepopulating with a user / person.

The permissions are all there (I think) which is proven by the component working when I start typing a user name.

Any ideas what I might be missing?

As always thanks so much for any input in advance.

----- edit ----

Oh okay, it seems that I can't use that prop with mgt-react? I have to use defultSelectedUserIds and can't just provide an email address. Can someone confirm this is the case?

Upvotes: 1

Views: 741

Answers (1)

Nic Vogt
Nic Vogt

Reputation: 271

Is there mgt documentation for the defaultSelectedUsers property? As far as I am aware, the people picker only supports defaultSelectedUsersById. The email address should work though, assuming the graph is able to retrieve the users (it's their actual id).

For a quick test, are you able to retrieve the users through the graph explorer with the /users/${id} (replace id with your email) filter? This is what we use for the property.

Upvotes: 1

Related Questions