2

How do I hide specific column when user search for an item?

For example, user searches for other people's names and the personal detail comes out but some detail should be hidden such as email.

Is there a way to customize the search results to hide certain columns for all users?

1
  • While this can be done "visually", savvy users can easily find content from the index that is not secure. Commented Jan 5, 2018 at 15:09

1 Answer 1

0

Assuming the SharePoint is 2013.

This can be achieved by creating a new Result Type and Search Display Template.

  1. Go to site collection's Site Settings -> Web Designer Galleries -> Master pages and page layouts -> Display Templates -> Search and download Item_Person.html.
  2. Open Item_Person.html and find var has_email. Set its value to false. Edit the title tag <title>Custom People Item</title> Save the file with a new name Custom_Item_Person.html and upload back to SharePoint at the same location. After few seconds SharePoint will create the corresponding Custom_Item_Person.js.

  3. Go to the search page and edit the People Search Core Results web part and click on result types under Display Templates.

enter image description here

  1. Create a copy of the Person result type.

enter image description here

  1. Give it a new name. Select the Custom People Item in the dropdown What should these results look like? and save.

  2. Edit the search page again and edit People Search Core Results web part. This time it should display Custom People Item in the result type dropdown.

  3. Test the search and it should hide the email.

Hope that helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.