top of page

Using the People Layout to display external users

Writer's picture: Kasper LarsenKasper Larsen

Updated: 10 minutes ago

On a few occasions I have seen people asking how to use the PnP Modern Search web parts to display external users, i.e. users who are not in the SharePoint User Application.

In most cases the reason for this request is that people want to show external parties in a similar way as the Department web part.



The final result (List based)
The final result (List based)

First, I looked at the old Contacts List from SharePoint Classic, and the content type it is using. I guess I could have used it, but it contained a lot of columns that I don't need, and it didn't have a photo column.


As the photo was the cornerstone of the content type I was going to use in this scenario, it looked like I had at least two options; add a Hyperlink column to a List content type or base the content type on Document., so I did both.


List based content type


Most of the columns will of cause be identical in the two options, but in the List based option I have added a Photo columns of type Hyperlink or Picture

Columns in the List based content type
Columns in the List based content type

So, if you have a link to a picture of the external person, then this option is optimal, as you don't have to maintain a library of picture of the external contacts. Just enter the URL to the picture, and you are done.

The Status column is just included in case I at some date wish to be able to exclude some of the contacts from Search in an easy way.

In this case I didn't have the URL to the pictures I wanted to use, so I had to add another library to store the pictures in.


Document based content type


Columns in the Document based content type
Columns in the Document based content type

In the Document based solution I don't need any URL column, but I will have to make sure that the pictures I upload to the library have unique names, otherwise I might overwrite an existing "document"




Once I had added a few items and documents I had to wait for the Search Crawler to pick up the columns and add the new crawled and managed properties (go for a walk or something similar, it can easily take a few hours).


ProTip: use either the SharePoint Search Query tool or the browser extension SP Editor (from here) to inspect the values returned from the API.


Setting up PnP Modern Search


Add a Results Web part, set it to use SharePoint as the data source.


In both cases the Query template was pretty simple:

{searchTerms} contenttypeid:"0x01000CCF62CA3284A346B04836E6545A1A3E0029A44546B025A047B72F48D5F2FA927E*"

The GUID is that of either the List or Document based content type.

Nothing prevents you from making the query more specific, like only showing the people working for the Contoso corp: CompanyOWSTEXT:Contoso


On pane 2 change the layout to the People layout, and set the Component size to Extra Large


Forget about enabling Presence or Persona card on hover, that will only work on accounts from the UPA.


Switch back to page 1


For the List based option

Add the following to Selected properties:

EMailOWSTEXT

FullNameOWSTEXT

PrimaryNumberOWSTEXT

URLAnchor

JobTitleOWSTEXT


Change the Layout slots as below:


Switch to the Manage people fields and update Image URL, Primary text and Optional text:

People fields for the List based approach
People fields for the List based approach


For the Document based option



Add the following to Selected properties:

EMailOWSTEXT

FullNameOWSTEXT

PrimaryNumberOWSTEXT

CompanyOWSTEXT

JobTitleOWSTEXT


Change the Layout slots as below:


Layout slots for the Document based option
Layout slots for the Document based option

Switch to the Manage people fields and update Image URL, Secondary text and Optional text:

the Secondary text is:

{{slot item @root.slots.JobTitle}} at {{item.CompanyOWSTEXT}}

And now it should look like this:






So, I hopes this walkthrough shows that the seach part is pretty trivial once you have the correct Information Architecture.


And feel free to add additional web parts and Refinables:



6 views0 comments

Recent Posts

See All

Comments


30103817

  • Twitter
  • LinkedIn

©2023 by M365thinking. Proudly created with Wix.com

bottom of page