How to show the org chart based on anothe user profile page?

Hi Team,

I have the Org-Chart setup on SP13 Enterprise on-premise. We are using User Profiles as the data source. I have created a page in the My Sites and dropped in the Org Chart webpart and it shows correctly for the logged in user (root id is kept as blank). I can see my org chart fine.

But the problem is, when I go to another person’s profile and click on the org chart I still see mine instead of seeing his org chart?

What we want is, every one is able to see every one else’s org chart. I visit the profile page of my colleague I want to see his org chart and not mine.

Can you help me out on this? We have the accountname=domain\user in the querystring in all the pages, may be we can dynamically set the root id from this?

Hi Mohamed,

Thank you for your question.

There is similar article which describes how to drill down to current user.

You can replace current user with parameter from URL. User GetUrlKeyValue function to get value from URL like this:

var currentUserLogin = GetUrlKeyValue("accountname")

Thus your code should look like this:

[code]var currentUserLogin = GetUrlKeyValue(“accountname”);
var isInitialLoad = true;

renderer.onLoadingFinished(function(){
if(isInitialLoad){
isInitialLoad = false;
renderer.drillDown(currentUserLogin);
}
});[/code]

Thank you, that worked. I need one more feature, when I am showing the Org Chart I see My Manager, and Myself. I need to see 3 levels here, My Manager, My Self, My Subordinates. I am using the following code as of now:

[code]var currentUserLogin = GetUrlKeyValue(“accountname”);
var isInitialLoad = true;

renderer.prerenderAction = function(completed) {
try {
var context = SP.ClientContext.get_current();
var web = context.get_web();
var user = web.get_currentUser();
context.load(user);

    context.executeQueryAsync(function() {
        if (currentUserLogin == "") {
            currentUserLogin = user.get_loginName();
        }
        completed();
    }, function(sender, args) {
        completed();
    });

} catch (e) {
    completed();
}

}

renderer.onLoadingFinished(function() {
if (isInitialLoad) {
isInitialLoad = false;

    renderer.dataProvider.getBoxGroupItemDataById(currentUserLogin, function(dataItem) {
        if (dataItem.ParentId == "")
            renderer.drillDown(currentUserLogin);
        else {
            renderer.drillDown(dataItem.ParentId);
        }
    });
}

});[/code]

Can you let me know how to achieve that?

Hi Mohamed,

Thank you for your question.

You can use this function:

renderer.expandNodeLevels(numberOfLevels, completed)

it will expand specified number of levels:
plumsail.com/sharepoint-orgchar … k/#methods