Share via


Organizational Browser Start Account

If you would like to create an Organizational Browser page that shows an entire organization or that starts at any user other than the one currently logged in you can do so with a Script Editor web part.  First create a page, add the organizational browser web part and a script editor web part.  The choose the appropriate source below for your script editor and replace the DOMAIN and SAMACCOUNTNAME/USERPRINCIPALNAME and SHAREPOINT_URL_INCLUDING_SITE (example https://site.domain.com/sites/sitecollection/subsite) appropriately.  This should set the starting user for both the Silverlight and HTML Views.

This based on combining information from:

https://social.technet.microsoft.com/wiki/contents/articles/23593.sharepoint-2013-organization-browser-web-part-does-not-render-in-html-view-for-windows-claims-users/compare.aspx?revB=0&revA=1

https://social.msdn.microsoft.com/Forums/vstudio/en-US/bea636a0-dbd1-41e0-b06c-3e7f8fd067d0/calling-a-specific-user-when-using-organization-browser?forum=sharepointdevelopment

and a few other sources

For SharePoint 2013


<script type="text/javascript">
function CreateHierarchyChartControl(parentId, profileId, type, persistControlId) {
    profileId = "DOMAIN\\SAMACCOUNTNAME";
    var initParam = profileId + ',' + type + ','  + persistControlId;
    var host = document.getElementById(parentId);
    host.setAttribute('width', '100%');
    host.setAttribute('height', '100%');
    Silverlight.createObject('/_layouts/ClientBin/hierarchychart.xap',
        host,
        'ProfileBrowserSilverlightControl',
        {
            top: '30',
            width: '100%',
            height: '100%',
            version: '2.0',
            isWindowless: 'true',
            enableHtmlAccess: 'true'
        },
        {
            onLoad: OnHierarchyChartLoaded
        },
        initParam,
        null);
}
 
function OnHierarchyChartLoaded(sender) {
    var params = sender.GetHost().InitParams.split(',');
    var profileId = params[0];
    var profileType = params[1];
    var persistControlId = params[2];
    sender.GetHost().content.HierarchyChartObject.SetPersistControlId(persistControlId);
 
    sender.GetHost().content.HierarchyChartObject.SetProfileServiceUrl('SHAREPOINT_URL_INCLUDING_SITE');
    var lastVisitedProfile = GetLastVisitedProfile(persistControlId);
    if (lastVisitedProfile != null) {
        params = lastVisitedProfile.split(',');
        if (params.length > 1) {
            profileId = params[1];
            profileType = params[0];
        }
    }
    sender.GetHost().content.HierarchyChartObject.SetNewProfile(profileId, profileType);
}
 
//HTMLView
SP.UI.Portal.SimpleProfileBrowser.prototype.$2S_0 = function ($p0, $p1, $p2) {
    $p0="DOMAIN\\SAMACCOUNTNAME";
 
    var $v_0 = $get($p1);
    if ($v_0) {
        $v_0.innerHTML = '<DIV></DIV><DIV></DIV><DIV></DIV>';
        this.$h_0 = $v_0.firstChild;
        this.$16_0 = this.$h_0.nextSibling;
        this.$1e_0 = this.$16_0.nextSibling;
    }
    if ($p2) {
        this.$h_0.innerHTML = String.format(SpsClient.ScriptResources.silverlight_Install_Message, '<a href=\'javascript:Silverlight.getSilverlight(\"2.0\");\'>Silverlight</a>');
        Sys.UI.DomElement.addCssClass(this.$h_0, 'ms-profileBrowserHeaderText');
        Sys.UI.DomElement.addCssClass(this.$h_0.firstChild.nextSibling, 'ms-profileBrowserSilverlightLink');
    }
    this.$2V_0($p0);
}
</script> ​​

 

For Office 365


<script type="text/javascript">
function CreateHierarchyChartControl(parentId, profileId, type, persistControlId) {
    profileId = "i:0#.f|membership|USERPRINCIPALNAME";
 
 
    var initParam = profileId + ',' + type + ','  + persistControlId;
    var host = document.getElementById(parentId);
    host.setAttribute('width', '100%');
    host.setAttribute('height', '100%');
    Silverlight.createObject('/_layouts/ClientBin/hierarchychart.xap',
        host,
        'ProfileBrowserSilverlightControl',
        {
            top: '30',
            width: '100%',
            height: '100%',
            version: '2.0',
            isWindowless: 'true',
            enableHtmlAccess: 'true'
        },
        {
            onLoad: OnHierarchyChartLoaded
        },
        initParam,
        null);
}
 
function OnHierarchyChartLoaded(sender) {
    var params = sender.GetHost().InitParams.split(',');
    var profileId = params[0];
    var profileType = params[1];
    var persistControlId = params[2];
    sender.GetHost().content.HierarchyChartObject.SetPersistControlId(persistControlId);
 
    sender.GetHost().content.HierarchyChartObject.SetProfileServiceUrl('SHAREPOINT_URL_INCLUDING_SITE');
    var lastVisitedProfile = GetLastVisitedProfile(persistControlId);
    if (lastVisitedProfile != null) {
        params = lastVisitedProfile.split(',');
        if (params.length > 1) {
            profileId = params[1];
            profileType = params[0];
        }
    }
    sender.GetHost().content.HierarchyChartObject.SetNewProfile(profileId, profileType);
}
 
//HTMLView
SP.UI.Portal.SimpleProfileBrowser.prototype.$36_0 = function ($p0, $p1, $p2) {
    $p0="i:0#.f|membership|USERPRINCIPALNAME";
 
    var $v_0 = $get($p1);
    if ($v_0) {
        $v_0.innerHTML = '<DIV></DIV><DIV></DIV><DIV></DIV>';
        this.$h_0 = $v_0.firstChild;
        this.$16_0 = this.$h_0.nextSibling;
        this.$1e_0 = this.$16_0.nextSibling;
    }
    if ($p2) {
        this.$h_0.innerHTML = String.format(SpsClient.ScriptResources.silverlight_Install_Message, '<a href=\'javascript:Silverlight.getSilverlight(\"2.0\");\'>Silverlight</a>');
        Sys.UI.DomElement.addCssClass(this.$h_0, 'ms-profileBrowserHeaderText');
        Sys.UI.DomElement.addCssClass(this.$h_0.firstChild.nextSibling, 'ms-profileBrowserSilverlightLink');
    }
    this.$39_0($p0);
}
</script> ​​