Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter WebPart "People Directory" #246

Closed
1 of 3 tasks
ricmaic opened this issue Feb 18, 2019 · 16 comments
Closed
1 of 3 tasks

Filter WebPart "People Directory" #246

ricmaic opened this issue Feb 18, 2019 · 16 comments

Comments

@ricmaic
Copy link

ricmaic commented Feb 18, 2019

Category

  • Question
  • Bug
  • Enhancement

Expected or Desired Behavior

Is there a way to filter the people you see in the webpart "People Directory" so that only specific users are shown?

For example, using an attribute of the AD account?

Observed Behavior

All users are displayed.

Thanks!

@bazookadaver
Copy link

I'd like to request this as well. We have admin accounts and service accounts and hidden terminated employees who show up no matter what. Looks unprofessional and I can't really use this webpart until we can filter. Appreciate you making it and can't wait for an update.

Thank you,

@mag210
Copy link

mag210 commented Feb 19, 2019

I've had the same issue but with the out of the box people search. For this webpart I think the best thing would be to create a bespoke Result Source where you add your exclusions to the query editor (for example only show users who have a department). However, this would then provide a different experience to the out of the box search results. Microsoft now provide a mechanism to exclude certain AD synced accounts from all 365 search but it's a bit messy and you basically have to hide them from the Address list via an AD attribute. https://techcommunity.microsoft.com/t5/SharePoint-Support-Blog/Exclude-Users-From-Delve-and-SharePoint-Online-People-Search/ba-p/170731

@bazookadaver
Copy link

mag210, if this webapp could be modified to exclude the SPS-HideFromAddressLists items, that would be great.

@ricmaic
Copy link
Author

ricmaic commented Feb 22, 2019

@bazookadaver could you already test mag210's link and check if it works? thanks.

@mag210
Copy link

mag210 commented Feb 22, 2019

@bazookadaver, you don't need to modify the webpart, if you follow the MS guide through you will hide that user from all of O365 including any SP search. We use it to hide our admin accounts which we don't want to appear in any 365 search, including delve. As I've said the other approach is to create a custom result source in SP and point the webpart at this. However, if you do this, it will only be the webpart that hides the accounts. I think a more holistic solution (depending on your requirements) is to exclude the accounts you want from 365 as a whole? Note this solution only works with synced AD accounts.

@bazookadaver
Copy link

I haven't been able to test yet, but will let you know. Appreciate the feedback.

@elpinto007
Copy link

elpinto007 commented Mar 12, 2019

I have this same issue where I have ex-employees showing up as well as admin/service accounts. I actually took the People Directory web part out of the solution and packaged it into its own solution so I can individually add it as required.

Anyways, for this, you can update the REST query in the PeopleDirectory.tsx. You can add a refinementfilter to refine the results you return from the query.

There is a flag in Exchange (msExchHideFromAddressLists ) which you can set in Exchange so users do not show up in the Global Address List..

This flag syncs with the User Profiles on SharePoint with the property SPS-HideFromAddressLists. You can add this in flag in the Refinement Filter for the REST api call. For example:

&refinementfilters='and(WorkEmail:("*@contoso.com"),SPS-HideFromAddressLists:(0))'

So I only search for accounts that have a work email address and the flag is not set.

@mag210
Copy link

mag210 commented Mar 13, 2019

That's a good solution for this webpart, its' just a shame that we can't amend the modern search query for the whole of 365, as your users will still show up in searches in portal.office.com and SP org searches. Hiding from the address list is a good partial solution but only works for synced on prem accounts

@elpinto007
Copy link

One of the issues I am having is to filter out Service accounts, or accounts that dont have anything in one of the attributes (eg Job Title is null). I tried doing a compound refinementFilter

refinementfilters=%27and(and(WorkEmail:("*@contoso*"),SPS-HideFromAddressLists:(0)),JobTitle:not(""))%27

But I am not sure if we can use the query to filter out Null values. I have spent quite a bit of time searching online to see if FQL allowed for this, but I cannot seem to find an answer. Does anyone know if something like this is possible?

@bcameron1231
Copy link
Collaborator

You unfortunately can't "filter" out null values, because you can't search against something that doesn't exist. The only way you'd do that is to search for items that do contain values using a bunch of concatenated ORs in the search query.

@elpinto007
Copy link

You unfortunately can't "filter" out null values, because you can't search against something that doesn't exist. The only way you'd do that is to search for items that do contain values using a bunch of concatenated ORs in the search query.

Ahh yes. I did come across that as a suggested solution. I think I can do some array manipulation after getting the result set. It wont be as efficient as filtering out in the query itself, but we have a small enough dataset so it should not cause as much overhead..

@eschrader
Copy link

I would like to filter out B2B user accounts

@elpinto007
Copy link

I would like to filter out B2B user accounts

I managed to achieve this, albeit not using the search query. I had to filter my results array and remove any entries that didnt have a "job title".

people = people.filter(function(Person){ if(Person.jobTitle) return Person; });

That worked for me.

@bcameron1231
Copy link
Collaborator

It looks like this question may have been answered.

Is it okay to close this ticket, or are you still looking for feedback?

@ghost
Copy link

ghost commented Dec 3, 2019

Closing issue as "answered". If you encounter similar issue(s), please open up a NEW issue. Thank you.

@ghost ghost closed this as completed Dec 3, 2019
@nehank08
Copy link

@elpinto007 Can you please let me know where did you add people = people.filter(function(Person){ if(Person.jobTitle) return Person; }); it in the file? Can you please send me your complete package of files?

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants