SharePoint 2007 – Org Chart Web Part Options

SharePoint 2007 provides the ability to view the profile of people within an organization and also to view a very basic organizational chart listing peers and subordinates.   I recently researched the options available for displaying a more advanced organizational chart and found there are several third-party web parts that provide this functionality for a fee, I also found a free option and also some sample code. 

At the SharePoint 2009 conference this year in Las Vegas I also saw a demonstration of a SilverLight web part that will provided as part of the SharePoint 2010 product that provide a really slick and interactive org chart interface (but you’ll have to wait for SharePoint 2010).  If you’re currently using SharePoint 2007, below are some good options for adding a better org chart to your site.

Third party Solutions

1OrgChart by ContentAndCode provides highly customizable org chart that is beautiful, especially if you store photos of your employees.  Some of the key features include:

  • Create organizational charts using information from User Profiles populated by Active Directory or another line-of-business applications
  • Online presence indicators allowing you to see when staff members are online and/or available.
  • Create organizational charts from a custom list
  • Create charts by organization, department or people
  • Decide which properties will be displayed
  • Decide the order in which properties will be displayed
  • Print charts as an image or to a printer
  • Expand/collapse branches in the chart
  • View personal profiles by clicking on a user name
  • Hide accounts that you do not want included in the charts
  • Search for people in the chart
  • Include or exclude photos from the chart
  • Limit the number of people to display in the charts
  • Automatically picks up the SharePoint site styles or theme
  • Turn on caching options to improve performance

SharePoint Org. Chart Web Part by KwizCom is a very nice solution at a very reasonable cost.  This web part isn’t as visually appealing as some of the other web parts but does provide a nice tree-view of the organization that other don’t provide.  It also has a nice pop-up window when you hover over an individual’s name, a nice touch.  Some of the key features include:

  • Hierarchical/flat view
  • Based on a standard Excel/XML file format, therefore enables easy integration with corporate HR system
  • Dynamically configurable view (you decide which columns should be displayed)
  • Textual & property-based filtering capabilities
  • Web part’s layout is fully customizable (CSS files and images)
  • Support filtering by URL parameters and by Web Part Connections

AA OrgChart by AASoftech is another low cost option which consists of three separate web parts.  The web parts work together to display organizational data in a tree view and also a searchable list view.  Some of the key features include:

  • Can directly connect to SharePoint User Profile on MOSS (SharePoint Server 2007)
  • Supports Multi Manager when connecting to SharePoint User Profile on MOSS (SharePoint Server 2007)
  • Can directly connect to SharePoint List
  • Supports XML data as input
  • Can also get data from SQL server, Access, Oracle, Excel, Text, SharePoint List, User profile or Active directory
  • Can lunch other application from the chart
  • Can display OrgChart in any Sort Order of the existing fields
  • Can display Query result (Employee Locator) in different styles
  • Can locate (Search) employee
  • Displays the Organization Hierarchy in Tree View as well as Chart View
  • Accepts Query string to browse the chart
  • Displays up to 11 data fields on "OrgChart" Web Part
  • Can browse the chart from specific Node

User Directory Web Part by Bamboo Solutions is an all-encompassing employee directory, employee search, organizational chart, and employee listing all wrapped up into a single web part that can be easily dropped onto any page in your site.  This is an amazing web part but if you’re simply looking for an organizational web part it may have (dare I say it) too much functionality.  The key features include:

  • View SharePoint and/or Active Directory users in a tree view structure
  • View and edit both Active Directory and SharePoint User Profile databases
  • Maintain and delegate security for profile updating to department level
  • Search for users by name or other metadata such as skill set, or user customized fields
  • Audit trail of changes to Active Directory
  • Maintain restriction on private and non-editable attributes
  • AJAX web part eliminates annoying post backs and enhances usability
  • Email notification when changes are made to profile database

Free Solutions

SimpleChart by ARB Security Solutions is a simplistic organizational chart displayed in a graphical manner.  This web part only accepts data from a SharePoint list, but with some creative thinking you can probably get your organizational data into a SharePoint list. 

Graphical Organizational Chart by Sue Hernandez is a set of fairly complete C# web part code using the Profile Manager and Google’s Org Chart API to display organization data in a nice graphical format.  She does a nice job of explaining the code and providing all the necessary pieces to build your own graphical display of your organizational chart. 

 

Feel free to comment if you find other solutions that you’d like to recommend.

SharePoint 2007 – Inline CSS Styles to Customize Pages

I am often asked to customize the layout of a page within a SharePoint site as a “one-off” change (one that affects only that page and not the entire SharePoint site).  This is typically a request to hide something on the page or to change the attributes of a font on a page, such as hiding the quick launch bar, hide the breadcrumbs or increasing the font on a header.  These changes are often small and don’t necessarily require a change to the site master page or style sheet (.css file).  One of my favorite tips is to use “inline CSS styles” to apply style changes to a page. 

My solution basically consists of adding a Content Editor web part to a page and including style sheet instructions that override the current page styling (as HTML style tags within the Content Editor web part).  The beauty of this solution is that it does not require changes to the site style sheet and can be isolated to just one page.  The down-side to this approach is that the change only impacts one page at a time, and you must apply this technique for each page you wish to change.

In this article I will provide you the specific instructions needed to inline CSS styles to customize your pages. 

Example Request: Hide the breadcrumb on our news article page.

Let’s pretend we’ve received a request to hide the breadcrumb line so that the page title is at the top of the page.  The user is basically asking us to make remove the words “Home > News > Sample News Article” and make the words “Sample News Article” appear at the top of the page.

blogpost1

 

Step 1: Add a Content Editor web part to the page and make it hidden.

Open the page in edit mode and add a web part to the page of type “Content Editor web part”.  You do this by using the “Site Actions” menu and selecting “Edit Page”.  Modify the properties of the web part so that the web part is hidden.  You do this by checking the “Hidden” box inside the Layout section of the web part settings panel.  Important note: Even though you’ve hidden the web part the CSS styles still effect the contents of the page.

blogpost2 

 

Step 2: Identify the styles to override in the HTML source of the page.

Open the HTML source of the page and look through the HTML for the area you want to effect.  Both Internet Explorer and Firefox provide a menu option for viewing the HTML source for a page; in Internet Explorer you’ll need to use the View menu and select Source.  After opening the HTML source you can search for the desired HTML area, In our case we can do a find on “Sample News Article” to find the breadcrumb area.  See the following code example; notice the CSS class named “breadcrumb” that is applied to the HTML “div” tag, we will be applying a change to the “breadcrumb” class to override the styling of the breadcrumb text.

<div class="breadcrumb">
    <span id="ctl00_PlaceHolderTitleBreadcrumb_siteMapPath">
    <span><a class="ms-sitemapdirectional" href="/Pages/Default.aspx">Home</a></span>
    <span> &gt; </span>
    <span><a title="Company News Home" class="ms-sitemapdirectional" href="/News/Pages/Default.aspx">News</a></span>
    <span> &gt; </span><span class="breadcrumbCurrent">Sample News Article</span></span>
</div> 

 

Step 3: Use the HTML Editor to add style tags to override the page styles.

Open the Content Editor web part and use the “Source Editor” button to add HTML directly into your page.  Enter your CSS commands in the middle of <style></style> tags.  See the example below where we override the breadcrumb div tag by using the CSS display property to hide the breadcrumb div.

blogpost3

 blogpost4

<p>&nbsp;</p> 
<style type="text/css"> 
    div.breadcrumb 
    { 
        display: none; 
    } 
</style> 

 

Step 4: Preview the page and make adjustments if necessary.

Save the changes to the Content Editor web part and publish your changes.  Be sure to preview the page to see if the CSS style overrides you applied are what you expected.  If not, you’ll need to back up a few steps and try again.

plogpost5 

 

My hope is that this technique of applying inline CSS styles directly into your SharePoint pages can give you another option for formatting your pages.  Again, this technique can be particularly useful when you have a change that affects only a single page and does not need to affect the entire SharePoint site.  Good luck and let me know if you come up with other creative uses for applying inline CSS styles.

SharePoint 2007 – Page Redirection / Bad Links Solution

Recently I was faced with this customer situation: “Replace my existing web site with a SharePoint 2007 site AND handle all the existing links to my site gracefully”.   Basically the customer asked me to build them a new public facing web site and asked that their existing page links (those in search engines, other web sites and links saved by their customers) continue to work and don’t become “dead” links.

I’ve heard this request when building Intranet sites and Extranet sites, but it’s probably most important when SharePoint 2007 replaces an existing Internet site because you have less control and contact with the audience.  With Intranet and Extranet sites you often have the ability to notify site users that the links to their sites and documents may be broken and you may even provide documentation and training on how to deal with the new site taxonomy.  With Internet sites you don’t have the same relationship with your users (customers) so your SharePoint 2007 site often has to handle the old links gracefully. 

With public facing sites you often reply upon search engines (Google, Live Search, Yahoo, etc) to find your site and you want to be sure that the stale links in those search engines do not lead to dead ends.  Most search engines today provide webmaster tools that allow you to remove dead links and provide updates site maps.  See my article on site maps for SharePoint.   Below are links to the three most popular search engine webmaster tools:

There are two basic approaches for solving the page redirection and bad link issues; 1.  Translate the http requests before they reach the site, or 2. Make the site “smart” so that it can redirect the http requests to the appropriate destination.

Things to consider before you begin building a solution:

1.  Identify all potential inbound links to your site and document those (I recommend creating a SharePoint list or spreadsheet).  Be sure to visit all major search engines to see what pages are indexed by those search engines, those links should be included in your list.

2.  Determine if your inbound links use query string parameters; for example: a link like http://www.kroger.com/privacypolicy.htm does not use query string parameters where a link like http://www.kroger.com/page.asp?tabid=143 does use query string parameters.  This will depend heavily on the technology used to implement the site you are replacing and may impact your choice on solutions.

3.  Identify the tools at your disposal; For example; is there a hardware-based firewall, a software-based firewall, load balancing software, load balancing hardware.  It is often easier to leverage one of these tools for page redirection rather than going down the custom programming path.

Solutions for handling page redirection include the following:

1.  Firewall or Load Balancing – Configure your firewall to “listen” for the set of inbound links and have your firewall redirect the request to the desired destination page.  If you are using Microsoft ISA Server you can enable Link Translation to handle the transition to the new addresses.  Other firewalls and load balancing solutions provide similar functionality to ISA, so be sure to check with your vendor.

2.  Custom Redirection Page – Implement a custom ASP.NET page inside SharePoint to handle all 404 errors.  

3.  Use the Codeplex Smart 404 Feature created by Josh Carlisle.  This is the solution I’ve used the most and I’ve found it very effective. 

In my next post I will guide you through the use of the Smart 404 Feature and provide you some sample code for extending the functionality of that feature.

SharePoint 2007 – Sitemap XML files for Better Crawling by Search Engines

If you are using SharePoint to build a pubic facing web site and you’d like your site to indexed (sometimes called crawled in SharePoint speak) by the popular Internet search engines (Google, Live Search, Yahoo, etc) you’ll want to pay particular attention to this article.  

By provide two XML files named sitemap.xml and sitemap_index.xml at the root of your site you will improve your odds of having search engines properly crawl your SharePoint site.  For example: http://www.example.com/sitemap.xml and http://www.example.com/sitemap_index.xml 

When your web site is indexed by search engines all the URLs listed in the sitemap file will be indexed and followed. The data provided in sitemap will let the search engine know what pages to crawl, the frequency the web page is updated and how important the page is to your site. Sitemap files do not totally guarantee your site will be indexed and receive high search engine rankings, however it is an important step to assist search engines which could lead to better results.

Here’s how the two files work together: sitemap.xml is an xml file that lists the pages in your web site, sitemap_index.xml is a file that references your sitemap.xml and allows you to provide multiple sitemap.xml files. 

Here is an example of what a sitemap.xml document should look like:

<?xml version="1.0" encoding="UTF-8"?>↵
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
    <loc>http://www.example.com/index.html</loc>
    <lastmod>2008-04-20</lastmod>
    <changefreq>monthly</changefreq>
    <priority>0.9</priority>
</url>
<url>
    <loc>http://www.example.com/news.html</loc>
    <lastmod>2008-08-22</lastmod>
    <changefreq>daily</changefreq>
    <priority>0.5</priority>
</url>
<url>
    <loc>http://www.example.com/tips.html</loc>
    <lastmod>2008-08-22</lastmod>
    <changefreq>daily</changefreq>
    <priority>0.5</priority>
</url>
</urlset>

Basically you want to have one <url> tagset for each page on your web site that you want indexed  The tag <loc> is the only required element inside the <url> tagset, the tags <changefreq> and <priority> are optional.

A sitemap.xml file should contain no more than 50,000 URL’s. If this is exceeded you will need to create a sitemap index file (sitemap_index.xml) which can contain up to 1000 sitemap.xml entries.  There are also facilities to compress your sitemap files if they become very large.

Here is an example of what a sitemap_index.xml file should look like:

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <sitemap>
      <loc>http://www.example.com/sitemap.xml</loc>
      <lastmod>2008-05-01T16:44:12+00:00</lastmod>
   </sitemap>
   <sitemap>
      <loc>http://www.example.com/sitemap2.xml</loc>
      <lastmod>2008-05-01</lastmod>
   </sitemap>
</sitemapindex>

There’s a great page that details out the complete specifications for sitemap files on the www.sitemaps.org web site.  Read the complete specification here.  

Sitemap and sitemap index files are simple to create if you have a small site, but how would you create one for a large site, one with many many pages or one with extremely dynamic content (adding pages, deleting pages, adding subsites frequently)?  The answer is to use one of the following tools (there may be more) to generate your sitemap files for you.  Both of the following software pages are written to explore a SharePoint site using the SharePoint object model, then create the sitemap files and automatically save them at the root of your site.

KWizCom SharePoint XML Site Map Builder

Tim Dobrinski’s sitemap tool

SharePoint 2007: Determine SharePoint Version

If you’ve ever tried to quickly determine the version of SharePoint 2007 that is installed on a server, this post is for you.  I’ve often thought that Microsoft should have displayed the SharePoint version on Central Administration under Operations, Servers in Farm.  However, they did not do this and you must examine the properties of files on your servers or the IIS web server to determine the SharePoint version running on the server. 

There are two basic ways you can determine the version:

  1. Navigate to the \12\bin\ folder and check file versions (For more information on the first technique read this TechNet article)
  2. Use IIS Manager and look at the web site properties

I prefer the second approach because it takes some of the guesswork out of the process.  The basic steps for using IIS Manager to determine the SharePoint version are:

  1. Sign in one of your SharePoint front end web servers
  2. Open IIS Manager (can be found by navigating to Start, Administrative Tools, Internet Information Server (IIS) Manager)
  3. Expend the folder labeled “Web Sites”
  4. Right-click on the web site named “SharePoint Central Administration” and select “Properties”
  5. Click on the tab named “HTTP Headers”
  6. Look at the field named “Customer HTTP Headers”
  7. Compare the value displayed for “MicrosoftSharePointTeamServices” to the following list.

(Please note: These instructions are written for Windows Server 2003, the instructions may be different for Windows Server 2008)

Special thanks goes to Penny Coventry for creating an excellent listing of the specific version numbers, build numbers and hotfix combinations. 

 

SharePoint 2007 – Hiding fields on NewForm.aspx and EditForm.aspx, the easy way

One of the limiting factors in using the default forms (NewForm.aspx, EditForm.aspx) is that there is no obvious way to hide columns from appearing in the form.  By default all columns in a list or document library will appear in your forms. 

After doing quite a bit of research on this I found a fairly easy way to hide fields by using JavaScript within the form pages themselves.  In my research I found several different sets of JavaScript code, but some of the scripts are easier to implement than others.  Below I provide the best and most straight forward JavaScript and some simple steps to guide you along.

To hide fields in a SharePoint 2007 form, follow these steps (I will use the NewForm.aspx in my example)

  1. Open SharePoint Designer and navigate to the site that contains the list or document library you wish to customize.
  2. Expand the folder named “Forms” under the desired list or document library.  You should see about seven .aspx pages (AllItems.aspx, EditForm.aspx, NewForm.aspx, etc)
  3. Open the NewForm.aspx page and switch to the “code” view to edit the HTML of the page.
  4. Paste the JavaScript code immediately below the the following HTML tag <asp:Content ContentPlaceHolderId=”PlaceHolderMain” runat=”server”>  This will add the JavaScript to the HTML inside the content placeholder tag.  Note: be sure to include the entire script below, including the <script and </script> tags.
  5. Modify the “hidefields()” section of the JavaScript code to refer to each SharePoint list field name to hide.  For example, the code sample below will hide the SharePoint fields named Title, Document Link, and PublishDate    Notice that you do not need to worry about internal field names or field types like other JavaScript techniques, you simply need to know the name of the field.
  6. Save the changes.  Select “Yes” when prompted to “…customize the page from the site definition…”
  7. Test the form

 

<script language="javascript" type="text/javascript">

_spBodyOnLoadFunctionNames.push("hideFields");

function findacontrol(FieldName) {

   var arr = document.getElementsByTagName("!");
   // get all comments
   for (var i=0;i < arr.length; i++ )
   {
      // now match the field name
      if (arr[i].innerHTML.indexOf(FieldName) > 0)
      {         return arr[i];      }
   }
}

function hideFields() {

   var control = findacontrol("Title");
   control.parentNode.parentNode.style.display="none";
   control = findacontrol("Document Link");
   control.parentNode.parentNode.style.display="none";
   control = findacontrol("PublishDate");
   control.parentNode.parentNode.style.display="none";

}
</script>

 

I hope you find this technique for using JavaScript to hide form fields in SharePoint 2007 as useful as I did.  Thanks to the guys at CleverWorkarounds for writing an article on this.

SharePoint 2007 – Branding Your Site Application Pages

If you’ve ever tried to customize the branding of a MOSS 2007 or WSS 3.0 site you’ve probably discovered that SharePoint application pages (pages that physically reside in the /_layouts folder on the file system) share a common master page and thus share the same style sheets.  Said another way; unlike SharePoint site collections and sites (where you can change the branding of sites by specifying different master pages and style sheets per site) your application pages all use the same master page (application.master) across all site collections and sites on a web application.

Examples of application pages include the following: groups.aspx, editview.asp, pagesettings.aspx, people.aspx, viewlsts.aspx … and many more, about 426 .aspx files in all.

To customize the branding on application pages I came up with a simple technique to dynamically apply different style sheets to the application.master by adding some C# code to the application.master file.  The instructions and sample code below assume that you want to load one of two style sheets depending on the host name (in this case we look for http://mosssitename/ and load the style sheet named css1.css otherwise we load the style sheet named css2.css)

1.  Add the following code inside the <HEAD> </HEAD> tags on your application.master file.

<asp:literal id="DynamicCSSLiteral" runat="server"/>
<script runat="server"> 
  protected override void OnLoad(EventArgs e) {     
    switch(Request.ServerVariables["HTTP_HOST"].ToString()) 
    {
        case "mosssitename":
            this.DynamicCSSLiteral.Text = "<link rel=stylesheet type=text/css href=/_layouts/1033/styles/css1.css />";
            break;
        case "localhost":
            this.DynamicCSSLiteral.Text = "<link rel=stylesheet type=text/css href=/_layouts/1033/styles/css2.css />";
            break;
        default:
            break;
    }
  } 
</script> 

2.  Modify the top line of your application.master file so that the @Master reference has the value AutoEventWireup=”true”.

<%@ Master AutoEventWireup="true" language="C#" %>

Feel free to reply to this post if you find any other solutions to branding application pages in SharePoint 2007.

SharePoint 2007 – Move Content and Configuration Databases

If you’ve ever wanted to relocate your WSS 3.0 or MOSS 2007 content databases or configuration database from one SQL server to another, you’ve probably found very little documentation and very little written on this topic.  Below is my attempt to provide some guidance for these tasks.  The steps are fairly simple, but please remember to try all operations of this magnitude on a development or test environment before trying this on your production SharePoint environment.

Move SharePoint Content Databases

Several common reasons for needing to move a content database from one SQL server to another are:

  • Scalability (spreading the load of your SQL server across multiple SQL servers)
  • Disaster Recovery (your SQL server had a catastrophic disaster and you need to recover from that event)
  • Database Reorganization (you simply need to change the server that hosts your content database or rename the database)

Instructions for moving a content database from one SQL server to another

  1. Detach the content database from the source SQL server and copy the .mdf and .ldf to the target SQL server. (Note: while you are moving the database files your users will see “Cannot connect to content database” when visiting their site)
  2. Attach the .mdf and .ldf files on the target SQL server as a new database (Note: this is your opportunity to rename the database if you desire)
  3. Run the following stsadm commands from the command line on your SharePoint server to complete the move:  (Note: the deletecontentdb does not actually delete the database from SQL server, it simply disconnects the database from SharePoint)

stsadm –o deletecontentdb –url http://yoursiteurl –databasename your_content_db –databaseserver source_SQL_server
stsadm –o addcontentdb –url http://yoursiteurl –databasename your_content_db –databaseserver target_SQL_server

Move SharePoint Configuration Database

Several common reasons for needing to move your configuration database from one SQL server to another are:

  • Disaster Recovery (your SQL server had a catastrophic disaster and you need to recover from that event)
  • Database Reorganization (you simply need to change the server that hosts your content database or rename the database)

Instructions for moving a configuration database from one SQL server to another

  1. Backup configuration database from the source SQL server
  2. Restore the backup onto the target SQL server (Note: this is your opportunity to rename the config database if desired)
  3. Run the following stsadm commands from the command line on your SharePoint server to complete the move:  (Note: the deleteconfigdb does not actually delete the database from SQL server, it simply disconnects the database from SharePoint)

stsadm -o deleteconfigdb
stsadm –o setconfigdb -connect –databaseserver target_SQL_server -databasename databasename -farmuser your_farm_sql_account -farmpassword your_farm_sql_password

 

The complete syntax for the stsadm -o deleteconfigdb is listed below: (Note: there are NO options)

stsadm.exe -o deleteconfigdb

 

The complete syntax for the stsadm -o setconfigdb is listed below:

stsadm.exe -o setconfigdb

           [-connect]

           -databaseserver <database server>

           [-databaseuser <database user>]

           [-databasepassword <database user password>]

           [-databasename <database name>]

           [-hh]

           [-exclusivelyusentlm]

           [-farmuser]

           [-farmpassword]

           [-adcreation]

           [-addomain <Active Directory domain>]

           [-adou <Active Directory OU>]

SharePoint 2007 – "Back" Link After Deleting a Site

After deleting a site in WSS 3.0 or MOSS 2007 the following page is displayed by default.  The “webdeleted.aspx” is a default application page provided by Microsoft, but it is easily customized.  In this article I will show you how to enhance this page to be more user friendly.

delete

The problem with this page is that the user is left hanging, with no links back to the parent site or site collection where the site was deleted from.  Below is a quick solution for adding a link labeled “Go back to parent site” to the top of this page.  When the steps are complete your users will see the following:

delete2

Steps for adding the “Go back to parent site” link.

  1. In notepad, open the file named “webdeleted.aspx” in the 12 hive, layouts folder (usually this is located at the following location: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS )
  2. Located the content placeholder tag: <asp:Content ContentPlaceHolderId=”PlaceHolderTitleBreadcrumb” runat=”server”>
  3. Add the following code inside the content placeholder:  <a href=”<%SPHttpUtility.HtmlEncode(SPControl.GetContextSite(Context).Url, Response.Output);%>”>Go back to parent site</a>
  4. Save the “webdeleted.aspx” file.

When you are finished the code should look like the following:

<asp:Content ContentPlaceHolderId=”PlaceHolderTitleBreadcrumb” runat=”server”>
     <a href=”<%SPHttpUtility.HtmlEncode(SPControl.GetContextSite(Context).Url, Response.Output);%>”>Go back to parent site</a>
</asp:Content>