YannickRe / spfx-msgraph-peoplesearch

Show and search users from your organization with an SPFx web part, through Microsoft Graph.
40 stars 33 forks source link

Dynamic results filtering like in PnP Search? #81

Open jussihi opened 6 months ago

jussihi commented 6 months ago

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 👍

YannickRe commented 6 months ago

Hi @jussihi ,

First of all thank you for the sponsoring (and the nice words), very much appreciated!

Now, as to your request: I wish I could build that too, it would be very helpful/useful in a lot of situations. Unfortunately, as far as I know, there is no efficient way to get a list of all distinct field values from Graph. With SharePoint Search, this is easy, as you can request the "refiners" when making a specific query. It will then return all distinct values for a field, like all distinct values for BaseOfficeLocation. Graph does not offer this functionality on the endpoint that we are currently using (/users), but only if we'd switch to using Microsoft Search. But in that case, you'd probably be better off using PnP Modern Search as it has all that functionality built in.

jussihi commented 6 months ago

Hi @jussihi ,

First of all thank you for the sponsoring (and the nice words), very much appreciated!

Now, as to your request: I wish I could build that too, it would be very helpful/useful in a lot of situations. Unfortunately, as far as I know, there is no efficient way to get a list of all distinct field values from Graph. With SharePoint Search, this is easy, as you can request the "refiners" when making a specific query. It will then return all distinct values for a field, like all distinct values for BaseOfficeLocation. Graph does not offer this functionality on the endpoint that we are currently using (/users), but only if we'd switch to using Microsoft Search. But in that case, you'd probably be better off using PnP Modern Search as it has all that functionality built in.

Hmmm... Ok! Thanks for the honest reply @YannickRe .

Would it be possible to even add pre-defined filters? I.e., so that one could predefine possible filter params and their values? So that JobTitles, Departments and Locations.. and whatever the user would like to filter? (and then the graph request under the hood would have the static $filter parameter value appended by JobTitle eq '<chosen predefined value>' ) etc..?

Damn, if I knew TS/JS and SharePoint better, I would already be doing this myself but I'm a complete no-can-do when it comes to web development. SharePoint feels to make it even harder :)

YannickRe commented 6 months ago

Theoretically, one could add a config option:

and then add a UI to show these refiners, and when a user clicks one value it would get inserted in the search query. It's not incredibly difficult to build, but would be a significant time investment...