SharePoint online - intercept document request when document clicked

350 views Asked by At

I am working on this project where it includes hosted app with SharePoint online and a dozen of other things.

  • When they built the project, they implemented a functionality that does this :

When a user goes to a document library, and clicks on the name of a document of specific type, the user gets redirected to the hosted app where there is a logic to do something on the document.

  • What I am not able to figure out is :

How are they implementing the part of "when user clicks on document, user will be redirected to app" ?

I checked httpmodules and couldn't find anything, I also checked remote event receivers and couldn't find anything..maybe I am not searching properly in the large C# solutions they have, or maybe there is another way to implement this..I need help to figure that out.

1

There are 1 answers

0
Mike Smith - MCT On BEST ANSWER

You would typically add JavaScript to the library page that finds the <a> tags for the documents with your file extensions, and then replaces the "onclick" with your custom code.

You could also intercept the JavaScript function used by SharePoint and add your additional logic. (do a web search for "SharePoint coreinvoke")

Disclaimer: most of what you will find is for the "Classic experience". The SharePoint Online "modern experience" changes all of the rules!