I am working with SharePoint 2013 Search and is working fine.

I am looking for a way to add link/action which will redirect user to edit/view page of document.

By default result is having document url and clicking on the link open the document.

Thanks in advanced.


I followed below steps,

  1. Add ListItemID managed property to SharePoint result
  2. Edit Display Template with below JavaScript and HTML

    var viewDocumentUrl = ctx.CurrentItem.ParentLink; viewDocumentUrl = viewDocumentUrl.replace("AllItems.aspx","") var viewDocumentHtml = String.format('View Property', viewDocumentUrl, ctx.CurrentItem.ListItemID);

    var editDocumentUrl = ctx.CurrentItem.ParentLink; editDocumentUrl = editDocumentUrl.replace("AllItems.aspx","") var editDocumentHtml = String.format('Edit Property', editDocumentUrl, ctx.CurrentItem.ListItemID);

  • If the document is in a folder, then the ParentLink property will link to that folder. Also, if the default view isn't AllItems.aspx, the string replace won't work. – Chris Romp Jun 14 '16 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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