Add MySite My Documents on any page

Add MySite My Documents on any page

With the new functionality in SharePoint 2013 to follow nearly everything users are empowered to keep track of all the stuff that they think is relevant. By default it is not shown on the MySite, but luckily there is a CodePlex project called I am following that uses the REST API to render a nice set view of all the users, documents, sites and tags you are following. You can use the examples to show information on any given page and are not only limited to your MySite.

However since SharePoint 2010 there was also a WebPart called SharePoint Documents that shows all documents that are authored by the logged in user where the user is a site member. A nice WebPart if you are working on an intranet and want to help users get an overview of their latest documents. However this WebPart can only be added to a MySite. If you add that WebPart to page other then the MySite you end up with an error stating that this specific WebPart can only be added to the MySite of a user. If you want to show such a view on a homepage of your intranet for instance you cannot do so by just exporting and importing the WebPart. Also if you are running Office 365 you cannot override or inherit the WebPart since you are bound to sealed or internal methods that prevent you from changing the WebPart it self. So you are either convicted to use the search and try to construct a query that represents the information you require or you try to build something yourself.

In my last project we encountered this problem, and when we started digging into it we found that the My Documents control eventually renders an i-Frame, and that there was a page that shows the actual info. The control that used on that page cannot be used to override since it is sealed but the page itself shows exactly what you want; an overview of all the documents (and tasks) of a the current user. The URL of that specific I-Frame will point to the following:


As you can see that it contains a ShowTask and a AccountName, and it will use a full URL to do so. If you however would use that knowledge to browse to a relative URL (/_layouts/MyInfo.aspx instead of the http://mysiteurl/MyInfo.aspx), and you would skipp the AccountName you would still see the data. Now at this point you could create your own html snippet to render that I-frame, however as you will notice the layout of that page looks a bit off. As it turns out that page is missing style sheets (or at least it is on all the O365 tenent that I know of). So using an I-Frame will give you the content that you want, but still leave you unable to change the design (and will make you look bad since the missing style sheets make it look rather ugly).

So I came up with a small piece of script that will use jQuery to retrieve the HTML of the /_layouts/MyInfo.aspx page and then select the table that contains the info we want, to render that on our page so that it will look like any given list view.

<script src=""></script>  
<div id="mydocuments" style="display:none;">Loading...</div>

<script type="text/javascript">
(function loadMyDocuments() {
    'use strict';
        $.get("/_layouts/15/myinfo.aspx", function( data ) {
            var myDocsPlaceHolder = $("#mydocuments");
            myDocsPlaceHolder.html($('table', data).html());

Just add the snippet to a ScriptEditor and you have an overview of all your documents on any given page you like.

Leave a Reply