Giter Club home page Giter Club logo

spfx-msgraph-peoplesearch's Introduction

Microsoft Graph People Search Web Part

Summary

Show and search users from your organisation, through Microsoft Graph. Search results show as a nice People Card, and display the Live Persona Card on hover.
The web part can be configured with a static search query, show a search box or accept a search query through a Dynamic Data connection to further filter the displayed results. Dynamic data can by default come from the Microsoft Search search box or the Page Environment. You could also use the Search Box Web Part provided by the PnP Modern Search Web Parts.

directory

As a code sample this clarifies the following concepts:

  • Connecting to Microsoft Graph using a SharePoint Framework web part
  • Implement efficient paging through large collections in Microsoft Graph
  • Use of $select, $filter, $orderby, $count and $search query parameters for Microsoft Graph
  • Implement batch requests to Microsoft Graph for fetching multiple resources in one network request

More information

I wrote a blog post covering more if the inner workings, you can find it at SPFx People Search web part based on Microsoft Graph.
Additionally, this web part has also been demoed on the PnP Community call of September 10th, 2020.

Used SharePoint Framework Version

drop

Applies to

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.


Minimal Path to Awesome

Either download the latest release OR build it yourself:

  • Clone this repository
  • in the command line run:
    • npm install
    • gulp build
    • gulp bundle --ship
    • gulp package-solution --ship

Install the package:

  • Add to AppCatalog and deploy
  • Assign 'User.Read.All' delegated permissions to the 'SharePoint Online Client Extensibility Web Application Principal', with CLI for Microsoft 365 or PnP PowerShell

CLI for Microsoft 365

m365 login
m365 spo serviceprincipal grant add --resource 'Microsoft Graph' --scope 'User.Read.All'

PnP PowerShell

Grant-PnPTenantServicePrincipalPermission -Scope "User.Read.All" -Resource "Microsoft Graph"

Acknowledgements / Inspiration

There are many web parts that aim to do the same thing, but they either use SharePoint Search as data store or they render their results in a completely different way. It's impossible to acknowledge all sources of inspiration to this solution, but I do want to give a shout out to two projects (and their contributors) that were foundational to deliver this solution as quickly as I did:

React Directory Web Part

The foundation on which I started building my own solution. This web part can be downloaded from the SharePoint Framework Client-Side Web Part Samples & Tutorial Materials

Thanks to

PnP Modern Search Web Parts

These web parts were an enormous inspiration on code structure and implementation approach. Their codebase is very impressive, and a lot of the code in this web part is a literal copy paste from them. You can find more on the PnP Modern Search Web Parts page.

Thanks to

spfx-msgraph-peoplesearch's People

Contributors

yannickre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spfx-msgraph-peoplesearch's Issues

Problem with VIVA in Teams Desktop App

We host a modern SharePoint site in SharePoint Online with your Peoplesearch web part.
There is no problem when I use a browser to view the sharepoint site.
We have integrated the site with the new MS VIVA app into teams.
And there is the problem. Teams Web shows the web part, but the Teams desktop app (Windows) often shows a red bar with an x at the beginning. Most of the time when I hit update it works.

I imagine it could be a timing issue.
When Teams opens, there is a lot of work to do in the background and there is a delay in displaying the web part.
This would also be supported by the fact that a PC that is very slow does not manage to display the web part in Teams (desktop app), but in the browser (teams.microsoft.com) it does.

This is what it looks like in the Teams desktop app

image

SearchService.ts return empty error message

I have a random bug, we have added You webpart at our Intranet site, and on Teams tab, on both pages/tabs site when user open SPO site and MS Teams first time (turn on the computer, lunch browser/ms teams) webpart showing only red bar without any error message. Refresh page or tab solving a problem.
In my opinion, the problem is in connecting to MS Graph. somewhere in src\services\SearchService\SearchService.ts at public async searchUsers(): Promise<PageCollection>.
I have no idea why my be a problem in our company infrastructure, not in w ms graph people search.

Because ist random and showing only on the first time when the page was the load I can not create steps to reproduce the behavior. I don't know why track issue or lunch some developer command in MS Teams

Any clue where I can start looking?
I have the same problem on v 2.3 and v2.5 with 1.0 or beta graphclient.

2 very minor toggle properties that provide extra config options.

Hi @YannickRe,

Thank you so much for this WebPart, it is awesome. I had a use case that meant it needed tweaking ever so slightly, I tried to do that myself (I am not a developer but used your existing logic in the code) and succeeded and have a working SPPKG (but I am also not familiar with forking code in GitHub).

I therefore submit these to you as potential additional config options which made this solution meet all my needs and I see others asking how to achieve similar things in the comments.

  1. I added a toggle option to display the search box alongside any of the search options ( I send a user to the page using a Query String value to initiate the search but then want them to be able to continue to perform other searches whilst on the same page using the search box). Currently search box and dynamic data are either/or.

  2. I add the option to toggle whether search is performed on page load so that if you want it blank to begin with and only display results after a search ( you advised the code to comment out to someone in this forum and I used that ).

Both of these were fairly simple to add by expanding your properties and adding if/else statements to use or ignore existing lines of code without changing any of the core code (that would have been beyond me).

Thank you again,
David

PeopleSearchToggleOptions

Not Working in Team

Working perfectly in SharePoint in the browser. But not working through the team app on mobile.

Being redirected to the SPFx redirect page: SPFx Single Sign On Redirect

Since a couple of weeks I am being redirected to the SPFx Single Sign On Redirect Page when trying to access a page where a peoplesearch webpart is set. The redirect page needs to refresh two times before users can read the page.

In the browser tabname the following title is shown -> SPFx Single Sign On Redirect Page.

I am automatically taken to this page:
[https://mytenant.sharepoint.com/_forms/spfxsinglesignon.aspx#code=...........

I've tried this on 4 different browsers (normal and incognito modus) all resulting in the same issue.

Live Persona Card not presented

Any additional step needed to get the Live Persona Card prompted when hovering or clicking a search result?
No LPC ist presented when I hover or click a search result.

Webpart not dynamically updating using Url Query String Parameter

Hi,

I am using the PnP V4 Modern Search Box (Page 1) standalone on one page and passing the search query as query string parameter in the url to a different page in a new tab that contains another PnP Search Box and People Search webpart (Page 2).
People Search (Page 2) is connected to the PnP Search Box (Page 2). PnP Search Box is configured to look at the Query String Parameter for search query. The query is passed successfully however the People Search does not dynamically update. I tried refreshing and it appears that the People Search loads the correct results for a quick second but then restarts as if no query was passed.

Profile Pictures not showing

Profile pictures stop appearing after you enter a $select statement. Remove the $select statement and profile pictures reappear as you can see in the screenshots below.
No Select Statement - Profile Photo
Select Statement - No Profile Photo

List view

Suggestion

List view for people search

I notice this was in earlier versions but is not avaliable anymore.
A list view would make the web part more usable across multiple scenarios.
Preferably with sorting on names implemented to accomodate both a view based on the alphabet, and search with more dunamic results.

Use substr in $filter query

I’m struggling with another problem of the webpart (or even more with the odata request). I would like to use substring of in the $filter parameter, but unfortunately it’s not working (-> invalid filter clause).

What I’m trying to to is: $filter: substring(‘OÖ’, department)
What’s working: $filter: department eq ‘LD OÖ’

Do you have any information what I should use for using substring?

Thanks a lot and best regards,
Evelyn

Filter and Query

Hello,

nice webpart by the way. Tried react directory but that not fits my use case cause there are shown guests and deactivated accounts. On graph the options are there but doesn't work porpertly.

The filter by it's own are working but not in combination. Also my query is not looking in the fields that i want to. I use the office field for product informations and want a search by much more fields.

Please can you tell me if my syntax is wrong.

Cheers
Patrick
2020-11-17 14_18_29-Window

User Card Display: Delay between User Profile Update and Populate to User Card

Describe the bug
I have noticed a delay with the user card displaying About Me details, about 24-48 hours after update in UPS. Usually happens for profiles that already have About Me text and are getting an update.

To Reproduce
Enter About Me details into user's profile.
Allow enough time for it to appear on the User Card (Contact tab, About Me section)
Return to user profile in UPS and update text of About Me field and save profile.
Refresh page and re-open user profile card
-- finding thatthe text has not updated and will take up to 48 hours (if not longer) to reflect the changes

Expected behavior
Expectation is that the updated text would appear shortly after the profile About Me field has been updated and save within UPS.

spfx deployment

Hi,
When I deploy the app to app catalog, I did not see the permissions listed

image

And I also did not have pending approval request in the API management

Do you know what cause it?Thanks

Show photo in people view compontent

Hi Yannick,
first of all thanks a lot for the fantastic webpart!
In my version the photo of a person is not shown in the view component - it just shows the initial letters of the person. When hovering, the personacard is showing everything fine.
Is there a possibility to add the photo to the overview, too?

Thanks a lot and best regards,
Evelyn

Edit search

What and where do you need to add to search also for 'jobTitle' and 'officeLocation'?

Search filters: Search by phone numbers

Hi,

This code is really great and works well in modern SP. Since lockdown, and more home working, users are getting calls from colleagues personal mobile phones. It would be great if they could search their user list using the telephone number to verify the caller. I have already implemented search changes to allow, for example, search by Department by changing resultQuery.query and including department:${this.searchParameter} but using mobilePhone in place of department rarely returns results. Does anyone have any ideas on this?

Card does not load correctly if selected person is guest

When the People Search picks up Guest users, the list view shows all of the correct information - display name, job title, email, phone - exactly as we've selected:
image

However, upon clicking a Guest users' card, it does not load properly like a standard member users'. Instead, it shows the display name as the UPN for the Guest, and no other information is loaded:
image

Syntax error

I keep getting this error after installing m365 CLI

Capture

Support for python3

I see an error during npm install that says the code is looking for python2. I'm pretty new to this so it may be a configuration issue. If you have any pointers, that would be great or do you have a code branch that supports python3?

Dynamic results filtering like in PnP Search?

Suggestion

Hello and first of all: thanks for creating this! Working with Graph is so much easier than with SharePoint search & SharePoint user profiles!!

What I would love to see in this app is a way to filter users by for example their:
Department
Location
Job title

In PnP search this is rather easy; I can simply use the "PnP - Search Filters" web part. Would this be a big trouble implementing here?

So something like this:
image

Here selecting "Sevilla" would only list searched users that are located in Sevilla.

Once again, kudos for creating this 👍

SearchBox and Live Persona Card not working.

@YannickRe Thank you for this cool web part and sorry to ask this under issues.

I've implemented this in our tenant and it's working fine except for the SearchBox and Live Persona Card.

image

image

static search also working, how can I add a search box? could you please show me the direction for that?

When it's come to Live persona card, it's working on the SharePoint default People web part and I've enabled the feature in configurations for peoplesearch web part. But it's not working.
image
image

spfx-msgraph-peoplesearch - Issue with npm install

I have cloned the repository and tried to run npm install in my environment within the top level directory, but keep receiving errors similar to the following:

npm WARN tar ENOENT: no such file or directory, open 'directorypath\spfx-msgraph-peoplesearch\node_modules.staging\office-ui-fabric-react-6e61ba8a\lib-commonjs\utilities\color\updateSV.d.ts'
npm WARN tar ENOENT: no such file or directory, open 'directorypath\spfx-msgraph-peoplesearch\node_modules.staging\office-ui-fabric-react-6e61ba8a\lib-amd\utilities\color\updateT.d.ts'
npm WARN tar ENOENT: no such file or directory, open 'directorypath\spfx-msgraph-peoplesearch\node_modules.staging\office-ui-fabric-react-6e61ba8a\lib-commonjs\utilities\color\updateT.d.ts'

Not entirely sure what I am doing wrong. Fairly new to spfx development, but I have successfully installed and modified other samples.

I have tried cloning through zip download and through GitHub desktop so I'm fairly sure I've got the whole repository.

Currently running npm version 14.15.5 which is a supported version for SPFX 1.12.1

I've attached an npm install log file in case that helps.
2021-06-07T11_09_43_301Z-debug.log

Search and view contacts: No action available to view more details about a person

It is currently not possible to open details / contact card for a person when viewing the results of a search from the mobile app (Android or iPhone). Search works fine, but there does not appear to be a click action to see more details. This means that I am not able to make a call / email the person from my mobile device. If I click on, for example, the author of a news story, the details for that person open, allowing me to contact them.

To Reproduce
Steps to reproduce the behavior:

  1. Open the SharePoint app on a mobile device
  2. Open a site containing this webpart
  3. Search for a person
  4. Click on their details
  5. No action is performed

Expected behavior
A contact card for this person is shown

WebPart not showing up after install

Describe the bug
The web part does not show up at all after install.

To Reproduce
Steps to reproduce the behavior:

  1. Go to AppCatalog
  2. Drop the sppkg and update over an old version
  3. Activate per site
  4. Not avaliable from the site I install it to

Expected behavior
Should show up among webparts after install on a site collection.
An old version worked, but after new install nothing shows up anymore where I had placed the webpart, and the new web part is not avaliable to put into sites.

Live Persona Card no longer working

Had this excellent web part up and working without issue. The live person card feature worked great and we have not done any configuration changes since.

Some point in the last week the live persona card stopped working. In the console I see a GET call to delve.office.com/api/v1/configuration/SPPeopleWebPart/en-US that is failing due to NET:: ERR_CERT_COMMON_NAME_INVALID

I don't know if that is the cause or something else. Is this still working for anyone else?

Connection to Vertical Webpart / Possibility of two Connections

Capture1

Capture2

Hello! Thank you for building this webpart, it is a great improvement as I was not satisfied with the modern-search solution either.

In my project I need to connect the people search webpart with two Things:
> Page Environment -> Search -> query
> PNP modern search vertical webpart (to show the people webpart only, when the "People"-tab on the vertical is selected)

Will there be the possibility to make two connections in the future? (I have tried to add it myself, but unfortunately without success.)

The connection to the Vertical webpart with the People Search webpart is different than how the connection with the Modern search results webpart to the Vertical webpart works. I have not found a way to configure "show only when the people tab is selected" as it works with the Modern Search results webpart. Is this a known problem? I have uploaded 2 Screenshots to show the issue. I am using modern search v4 webparts.

Thanks in advance for your efforts.

People search web part shows error when we refresh page.

Hello Team,

I got below issues when i add people search webpart to the page it works fine sometime but some time when we do page refresh then this error display. After multiple hard refresh this error gone.

  1. TypeError: e.resizeTrigger.contentDocument is null
  2. TypeError: Cannot read property 'defaultView' of null

Kindly provide me workaround for this issues.

Thanks

Token request previously failed

Hi,

I've added the app to our SharePoint Online with only Azure AD, that is working fine.

Now I've also placed this app to a SharePoint connect with Azure AD and also an on premise AD.
When placing the app I get the notification "Token request previously failed"

Do you've any idea how to solve this problem?
I've googled, but didn't find anything so far.

I hope you can help me.

People Search default value

Hi Yannick,

I am trying to use your webpart to implement people search page. I have configured the searchbox option and selected show blank if no result radio button. The search results come up fine when searched through search box but if I click on close button next to search term in the search box all the people profile from entire tenant shows up instead of blank. I was expecting to see nil results when the search term is cleared.

Do let me know your thoughts on this.

exclude inactive users

The web part is displaying all the users and i would like to exclude inactive users. how can i do that

thanks!

Search functions

Hi,

When you search on a job title with an "&" in it, it doesn't work. Is this possible to make this work?
Also the search term has to start with the beginning of the name or whatever you looking for. Is it possible to search on a term that contains the job title?
By example, the job title is "Servicedesk Engineer". If you use the search term Engineer, you wouldn't find anything.
It would be nice if the people with the job titlte Servicedesk Engineer will appear.

WebPart Settings: not visible after adding to page with pnp-modern-search webpart

Describe the bug
Same as bug reported in pnp-modern-search issues list

To Reproduce
This time, I created a new Team site and a new Communication site in my test tenant.
-- looking to see if there was an issue with the site or the Site Pages library.
Created a new Site Page in both, then added the People Search webpart (after updating to the current version in the app catalog).
Published the page, refreshed, and then edited the page. Could see the settings just fine.
Added the pnp-modern-search webpart, published the page and refreshed.
Went back into edit and now the setting for the people search are blank.

Occasionally get a message in the settings pane:
"No settings available. The web part or dashboard card using this property pane was deleted."

Expected behavior
Settings should be visible for webpart when editing the page

Screenshots
image

Unable to display business phone

When selecting the persona fields, I am unable to get the business phone to display. I've tried 'phone', 'telephone', 'businessPhone', 'business' etc. but all return a blank. 'mobilePhone' works fine.

Can you confirm what the correct field name for business phone is please?

Guests - Insufficient privileges

When viewing a page that has this implemented as a Guest user, the page refreshes a couple of times and then displays a small red box with:

"Insufficient privileges to complete the operation."
Callum Corrigan -2023 06 08 - 20 56@2x

Queries

Hi Yannick

This is an excellent webpart. Thanks for sharing. I have manged to install and embed the webpart to my SPO site but would like to do the following:

  1. Hide Linkedin from LPC
  2. Connect the webpart to a refiner webpart

Any suggestions how this can be achieved?

Many Thanks & Regards

Live Persona Card: Full information only shown for my user

Description of bug
People search webpart works well on my tenant site but when I deployed to a specific project site, there is a strange error. Live persona card only shows full information about me, although the other users have also relevant data, live persona card only shows mail for them. When another account logs in then it can only full information about itself in same manner and cannot see the others full information.

Me on live persona card:
image

Other users on persona card:
image

I have already checked the code for live persona card render, but the it gets the same props for me and different user, but still renders other users with missing information. Also, search-bar result for other user live persona card in this sharepoint site works just fine.

Site search result for same other user:
image

To Reproduce
Steps to reproduce the behavior:

  1. Go to hover a person card and then click on it.
  2. See the results information for person in live persona card content.

Expected behavior
It should not only show me all information related my user in live persona card but also needs to show other users' information once I clicked to their persona card to open up live persona card.

Additional context
As far as I understood, this bug does not occur every sharepoint site, I really does not understand why it happens and also tried to change the live persona component id with default search live persona card id but i still get the same results.

Issue displaying user photos

Hi,

I have managed to implement the web part into our intranet and it is working great, however the one issue we are having is that it is not pulling all user photos, only some.

All of our users are on Exchange Online, and most do have photos - these show both in Azure and when running the GET "https://graph.microsoft.com/beta/users/UserIdOrPrincipalName/photo/$value" query in the MS Graph Developer area

Are you able to provide any ideas as to why this may be happening please?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.