Make SharePoint 365 (online) search results link to document instead of DispForm.aspx

New Contributor
We have a list in SharePoint and show the results for the users.

For Office or PDF documents, the link in the result set is for the document itself - that's what we want.

For images and videos, the link goes to DispForm.aspx instead, so when clicked opens the document details.

I found a possible solution for this if we were using SharePoint Server: Make SharePoint search results link to document instead of DispForm.aspx with no iFilter

In our case, we are using SharePoint 356 online. Any idea on how to do the same there?

Thank you.

3 Replies

@naretto 

We have the same problem in our custom search solution. As far as I know there is no configuration change to fix this for SharePoint Online.
explorerDispForm.aspx.png

When a user selects a link to a dispform.aspx we first use the UniqueId to retrieve the serverRelUrl
https://<tenant>.sharepoint.com/_api/web/GetFileById('3E68DB01-1F77-4E46-8E39-1D18592DEF3A')
and then we can display the image in the browser. The performance impact is negligible since the additional request takes < 100 ms.

 

Hi @Paul_HK_de_Jong,

Thank you for the idea. I may go down that path.

Just to clarify, did you change DispForm.aspx to make that redirect?

Would you have a few more details to share?

Thank you

@naretto 

We are in a fortunate position that we have a custom solution.

Basically we show a search bar in our custom solution and use search rest api to execute the search request. We display the search results in the desired sorting sequence.

The link for images does not open the DispForm.aspx but invokes a custom JavaScript function which uses the UniqueId from the search results to invoke a get request:
https://<tenant>.sharepoint.com/_api/web/GetFileById('3E68DB01-1F77-4E46-8E39-1D18592DEF3A')

(the guid shown is the UniqueId from the search result)

explorerDispFormGetID.png

The response to the GetFileById request contains the ServerRelativeUrl which is then used to display the image in the browser. Too bad we need this intermediate request. Happy coding.