Forum Discussion
naretto
Oct 28, 2022Copper Contributor
Make SharePoint 365 (online) search results link to document instead of DispForm.aspx
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,...
naretto
Oct 28, 2022Copper Contributor
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
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
Paul_HK_de_Jong
Oct 28, 2022Iron Contributor
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)
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.