0

I'm using React 16.12.0 and

import { SimpleProvider, Providers, ProviderState } from '@microsoft/mgt';
import { PeoplePicker, People } from '@microsoft/mgt-react';

versions "^2.0.1".

What I didn't found is:

  1. how to use promise when using defaultSelectedUserIds and passing default IDs to be loaded. When page is loading PeoplePicker input is empty and after few seconds is loaded with data. Does PeoplePicker supports promise?

  2. When passing default Ids to defaultSelectedUserIds, data in the object "e.target.selectedPeople" is loaded like:

    @odata.context: "https://graph.microsoft.com/v1.0/$metadata#users/$entity"
    businessPhones: []
    displayName: "<user_name>"
    givenName: "<name>"
    id: "<user_id>"
    jobTitle: null
    mail: "<user_mail>"
    mobilePhone: null
    officeLocation: null
    preferredLanguage: null
    surname: "Marinov"
    userPrincipalName: "<user_mail>"
    __proto__: Object```
    
    

which is different if we add a new user, where object contain more data:

    ```2:
birthday: null
companyName: "<comapany_name>"
department: "<comapany_department>"
displayName: "<user_name>"
givenName: "<name>"
id: "<user_id>"
imAddress: "sip:<user_email>"
isFavorite: false
isFocused: false
jobTitle: "<user_job_title>"
officeLocation: "<office_location>"
personNotes: null
personType: {class: "Person", subclass: "OrganizationUser"}
phones: [{…}]
profession: null
scoredEmailAddresses: [{…}]
surname: "<name>"
userPrincipalName: "<email>"
yomiCompany: null
__proto__: Object
length: 3
__proto__: Array(0)```

is this normal behaviour or I can load same set of data when using 'defaultSelectedUserIds' ?

Thanks

Tsvetelin
  • 221
  • 1
  • 3
  • 7
  • The defaultSelectedUserIds property is only used for setting the initial state of the component. The `seletedPeople` property retains the true state. The Graph endpoint for the user by `user-id` property [/get/user](https://learn.microsoft.com/en-us/graph/api/user-get?view=graph-rest-1.0&tabs=http) returns a default set of user properties as you've listed above. The users [endpoint](https://learn.microsoft.com/en-us/graph/api/user-list?view=graph-rest-1.0&tabs=http) is used for typical searches. – Nic Vogt Jan 05 '21 at 18:44
  • defaultSelectedUserIds - yes, this I want to do. I have a form where I'm using PeoplePicker and next time when a user goes to edit the request, I'm getting user ids from DB and set them as array to ```defaultSelectedUserIds={getUsersIDs}``` so I can load them. Regards seletedPeople - this contains current array of people, but don't see how I can use it to promisfy the request? – Tsvetelin Jan 06 '21 at 07:53
  • You might be able to use the [caching](https://learn.microsoft.com/en-us/graph/toolkit/customize-components/cache) feature to store the users. See the example implementation for a . – Nic Vogt Jan 13 '21 at 22:36
  • @Tsvetelin Where you able to find a solution? – David Arias Apr 02 '21 at 19:05

0 Answers0