Organization browser web part can be easily used inside pages of the portal with default behavior of showing the current user as the selected profile which appears in the center of the organization browser when the page loads.
However, sometimes you might prefer to show a different user by default, for example – a department’s page where the manager is shown with all his employees. Unfortunately, the organizational browser web part does not come with suitable properties which allows us to tweak the web part.
Microsoft made an effort to make it hard to change it and even after I opened the hierarchychart.xap file I couldn’t find any way to go around the problem.
After playing with the web part and comparing the same page with and without the web part I came to a solution which allowed me to display the organization browser with a selected profile of my choice. In order to achieve this goal I used the content editor web part which loads a static htm file with the following code which than creates the organizational browser.
The code has2 main regions:
1) The JavaScript which usually rendered by the web part is responsible for loading the control. One thing you need to change is the url of the current site (see highlighted text).
2) The html code contains the <object> and <input> which is required for some reason (probably accessed from Silverlight somehow). Notice you have 2 locations where you need to type the root user in domain\user format.
<script>
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('http://yousiteurl');
// Check if this is returning session, pulling out profile from cookie
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);
}
functionHideControls(controlIds) {
for(i = 0; i < controlIds.length; i++) {
var control = document.getElementById(controlIds[i]);
if(control != null) {
control.style.display = 'none';
}
}
}
functionGetLastVisitedProfile(persistControlId) {
var control = document.getElementById(persistControlId);
returncontrol.value;
}
</script>
<inputname="ctl00_customorgbrowser_ctl00"title="This web part displays an interactive view of your company's users and organizations. A preview is unavailable for this web part because it requires Silverlight."id="ctl00_customorgbrowser_ctl00"style="display: none;position: absolute;"type="text"value="User,domain\user"/>
<objectwidth=600"height="600"id="ProfileBrowserSilverlightControl2"data="data:application/x-silverlight,"type="application/x-silverlight">
<param name="top"value="30"/>
<param name="enableHtmlAccess"value="true"/>
<param name="source"value="/_layouts/ClientBin/hierarchychart.xap"/>
<param name="initParams"value="domain\user,User,ctl00_customorgbrowser_ctl00"/>
<param name="windowless"value="true"/>
<param name="onLoad"value="OnHierarchyChartLoaded"/>
</object>
Once uploading the html file to a document library it can be used to display the organizational browser using a content editor.