I’m a huge fan of the SharePoint 2010 Organization Browser, the Silverlight web part that displays the company hierarchy based off of the Active Directory Manager field. However, my biggest complaint was that there was no way to set the default user – meaning I want when the page loads for the focused user to be say a CEO or Department Head instead of me. The easiest solution would be to promote me to CEO, but that didn’t fly to well in the office. So, I had to turn elsewhere.
I knew that there must be a way because within My Profile on the Organization tab it takes you to a query string named accountname followed by domain\username. I just had to figure out how this page was generated and then I could solve my issue with the web part – and I did!
This solution works perfect when needing a company organization chart that you can link directly from say the top navigation or via an About Us page. You could also take it a step further and do this for every department’s top level site and show the organization chart starting with the Department Head.
Pre-Reqs
- A web part page or page with the OOTB Organization Browser web part added
- Account name for your CEO or Department Head
- Access to SharePoint Designer 2010
Steps
Open SharePoint Designer 2010 and navigate to the page where you have added the Organization Browser. Right-click and select Edit File in Advanced Mode
Using either Split view or Code view, navigate to the top of the code and locate the maroon colored Register statements. Copy and paste the below at the end of the last Register statement:
<%@ Register Tagprefix=”SPSWC” Namespace=”Microsoft.SharePoint.Portal.WebControls” Assembly=”Microsoft.SharePoint.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
Next, locate PlaceHolderMain (CTRL+F for Find) and copy and paste the below directly under it on the next line:
<SPSWC:ProfilePropertyLoader id=”m_objLoader” LoadFullProfileOfCurrentUser=”true” runat=”server”/>
Now, save the page and you are customizing the page so click Yes on the warning screen.
All you have to do now is simply navigate to the page from a browser but include ?accountname=domain\username after aspx in the URL
Example: https://portal.company.com/OrgChart.aspx?accountname=CONTOSO\chris.johnson
Again, make this a link for “Company Org Chart” from the top navigation or a link to the HR site with the HR Department Head’s account name in the query string. Now, I believe, we can truly use the Organization Browser web part for its full potential.
Pingback: Start the Organization Browser at any Account Name « SP2010 Blog
Thanks, Adam!
Great post, and it works perfectly if you remember to replace all the double quotes in these two line you provide with standard quotes, i.e. ” instead of ” – a small change it may seems, but without it you will get errors!
ERROR
‘http://servername/my/Person.aspx?accountname=%5Cmyname‘ is not a valid identifier.
What am i doing wrong here?
Can you please provide me more information.
I am having hard time following your instruction.
I can’t seem to locate the file named OrgChat.apsx anywhere. Is it pre-installed on the SharePoint Server? Or do i have to separately install a separate webpart? Please let me know.
I need your help.
Thank you!
OrgChart.aspx is just what I named my blank web part page (see Pre-Req #1). You can name yours anything you would like to.
Thank you so much for your reply.
I am still having an issue with this.
I keep getting “SPSWC” is not a valid value for attribute ‘tagprefix’.
Can you please help me one last time. It will be greatly appreciated.
Thank you so much.
You need to change the quotation marks in the code view for your page you have created to house the Org Chart.
Copy and pasting both the lines of codes put a different format of quotations which are not compatible with the asps decoding of the web browser, hence you get the erros denoting what line there is a problem.
Go to the two lines of code you pasted and get rid of the quotation marks which appear at a slanted angel for regular-more veritcle style of quotations like this…”codecodecode”…
Fixed the erros I was getting
Pingback: SP2010 Useful Links « Nilesh Rathod
Hi,
Is it possible to avoid passing account name in query string and make this as a web part property? I want to display this org chart on a page alongisde other web parts and I am not sure if passing a specific account name in the url will impact other web parts on the page.
Thank You
That would be nice, but I doubt it. This web part provided out of the box by Microsoft is pretty locked down in terms of what you can do with it development wise – especially being a Silverlight control. So, I would not get your hopes up on that one.
I am getting following error when i have followed above steps. please help
“The version attribute on the register directive is not allowed in this page. “
Hi Adam,
Thanks so much for the useful blog. We did implement the change, and it works fine – giving the Head of Department account Id in the URL.
Unfortunately, it is now showing my account as Head of the org chart(or for that matter whoever logs in, it shows them their account as Head of the org chart). Any idea if this is a known problem, I followed all your steps above, and I saw it work, just that it is showing this wrong behavior now.
Thanks in advance.
Regards
Bala
The OOTB capability of the org web part is to start the user who is logged in at the top, so this leads me to believe that you may have missed a step. Double check your steps and URL to make sure everything is good to go.
I am getting following error when i have followed above steps. please help
“The version attribute on the register directive is not allowed in this page. “
I am getting following error when i have followed above steps. please help
“The version attribute on the register directive is not allowed in this page. “
Thank You.
Hi Adam,
I have done the changes suggested and the orgazation browser load up fine but shows only one user!! with out the account details in the url shows the logged in user and providing the account details in the url shows their detail only in the organization browser. Have you seen this behaviour? same changes works fine from MySite, Can’t see what is causing the prblm any suggestions pls?
Regards,
Santhosh
Has anyone managed to code the page so that the user account is embed in the page code with the webpart? I want to have an org browser as a part on the page, and for it always to display the fixed department head, even if the users managed to click a link that didn’t contain “accountname” in the URL (e.g. from a search, or directly from the page library). This webpart would be brilliant if it just had a simple “Default Account Name” parameter instead of all this faffing.
Otherwise, this is a great article, thanks. It does exactly what it says on the tin and works perfectly.
Thanks
Chris
Chris -
Thanks. I’m glad you like the article. I agree 100%. If it just had a couple of configurable options this web part would be unstoppable! Let’s keep the fingers crossed for this in SharePoint vNext!
Hello Adam,
When I add the webpart and go to the url, the OB Webpart does not scroll up, down, left nor right. Could there be a scripting issue. However it does work and show the proper information.
Thanks,
Kamesha
Hi Adam,
This is a great work-around, thanks very much for sharing.
-Paul
Hi Adam,
Thnx for sharing this, it was a great time saver. I added these Tags on Page Layout becose I m using Publishing Site. And it worked fine.
One quesiton – If user id (domain\lanId) in QueryString is incorrect (Not in AD) is throws an exception & shows error page. Is there any way to handle it ?
Neways thnx & waiting for your revert on this.
Kaushar