Tips for Devs #1: Enumerate Farm Sites and Pages
23. June 2009 08:14

I've decided to do a little series on SharePoint Tips for Developers, which will focus on common tasks that aren't immediately obvious, hopefully saving people some time in their day to day work.

Our first tip is about enumerating the objects in your farm.  Specifically, taking an SPFarm object, finding all the web applications in the farm, all the sites, and all the pages within them.  Some portion of that enumeration is likely to come up quite often in your work.

First, Getting all Web Applications in a farm is probably one of the lesser known tasks:

SPWebService webService = farm.Services.GetValue<SPWebService>("");
foreach (SPWebApplication webApp in webService.WebApplications)
{
//Do Something with Web Application here
}

In the above example, the variable farm is an SPFarm object, which you can get in a variety of ways, depending where your code is running.  In a timer job you might just do "this.Farm" -- in a web part you can get the farm from the site object in SPContext.Current.


Now we can go through all the sites and webs.  Probably the simplest way to do this is to loop through the Sites collection of your web app, and call a recursive helper function on each web, which will enumerate through all child webs regardless of depth.

        foreach (SPSite site in webApp.Sites)
{
//Pass web to helper function to enumerate
GetWeb(site.RootWeb);

}
        private void GetWeb(SPWeb web)
{
//TODO: Do something with the web object

//Process the sub webs recursively
foreach (SPWeb subweb in web.Webs)
{
GetWeb(subweb);
}
}

Once you have the web, there are a variety of ways you might find the pages you are interested in.  For example, if it is a publishing site you might want to find all the Pages libraries and get only the published pages -- You could do this with the web object you have available in GetWeb(...):

        foreach (SPList list in web.Lists)
{
if(list.Title == "Pages")
{
foreach (SPListItem item in list.Items)
{
if (item.File.Exists &&
item.File.Url.EndsWith(".aspx") &&
item.Versions[0].Level == SPFileLevel.Published)
{
//Do something clever with the page which is item.File.Url
}
}
}

Note that above we check if the item is published by looking at the level attribute of the version.

Tags: , , , Comments (1) | Permalink
Enterprise 2.0, Powered by SharePoint
2. May 2009 06:57

"Web 2.0" is old news now right? How about "Enterprise 2.0"?  What does technology and social interaction inside the enterprise look like when we start to leverage some of the concepts we've developed for public networks?  Perhaps even more important -- What tools do we use to power social interaction within this new paradigm?  Are they the same tools we used on the web, or altogether different?

 

Let's start by overcoming the buzz words.  First, "Enterprise 2.0" refers to two thing, the corporate social network and collaboration.  The former being something relatively new (but known), and the latter being something we've been getting good at for quite some time.  Social Interaction through technology, or social networking, is something we are all very familiar with in our daily lives on FaceBook and Twitter.  But what does the Corporate Social Network look like?  What does it even mean? I took my best shot at defining it:

"A corporate social network focuses on building communities of people who share related responsibilities and goals, or who can increase productivity through awareness of the responsibilities and goals of others."

So where our public social networks focus on building communities of people with similar interests, our corporate social network builds communities of people with similar responsibilities, and perhaps more importantly, communities of people who can benefit from the awareness of others responsibilities.

 

How do these people benefit from the network?  The primary benefits focus around the awareness factor --Awareness of who in the organization knows what and who knows whom.  For example, the sales division can have insight into exactly who is an expert on a particular product's features, or who in the organization may have a personal contact inside a client organization.  Knowledge can be transferred and preserved with greater ease through wikis or blogs, and collaboration can be dramatically enhanced, even across geographical boundaries by connecting people based on their roles and needs within the enterprise, instead of their physical locations.

 

The other half of this equation, Collaboration, is equally important.  There is little use in my participating in a community with my coworkers if we are unable to create productive outputs, whether they be documents, clients, ideas, or anything else that is relevant to our organization.  SharePoint Server has clearly differentiated itself in being able to quickly solve the collaboration problem.  When used properly it enables users to find information quickly, collaboratively share information in workspaces, and track this collaboration.  But when you actually create one of these pieces of information, or find a relevant item, what other information do you most likely need next before you can act?  Most often you are now faced with contacting someone mentioned in the document to ask some type of question:

  • How was this information used?
  • Was it successful?
  • Who worked on creating this?
  • Why did they create this?

This is where Collaboration begins to benefit from the Corporate Social Network.


So what features do we need, and how does SharePoint help?

 

There are literally thousands of social networking patterns that have been implemented with various degrees of success, everything ranging from GeoTagging to Mobile Status-casting.  Every organization will benefit from different facets and interfaces that can be applied to the underlying data model.  Here I have pulled out some of the more common patterns that most organizations will benefit from.  Along with each I provide commentary on implementation ideas.  Hopefully these will spur ideas for you to leverage within your organization.

 

Feedback Mechanisms are perhaps one of the most valuable first steps in opening the two way communication channels that can truly influence change in the management of processes and an organization as a whole.   Feedback can be provided on documents, articles, pages, policies, or virtually any data stored in the portal.  This may include:

  • Comments
  • Reviews
  • Ratings

While most of these features are not native on the SharePoint platform, they are often trivial to create.  A related list and some creative data views are in many cases all that is required.  The Community Kit for SharePoint already has a blog and wiki with full-featured comments and discussions.  Ratings are available through the SharePoint Tool Basket on any list, issue, document, link, or calendar.

 

Collecting  refers to any features that allow a user to build a collection of items that they find interesting or useful within the organization.  This may be documents, links, how-to's, or even people.  Examples are:

  • Savings content
  • Subscribing to alerts
  • Adding to a 'favorites' list
  • Subscribing to RSS

Frequently there will be custom collections based on the type of organization a user is working in.  An energy company may have "My Oil Rigs" collections and a sales organization may have "My Clients" lists to aggregate relevant entities that a user can benefit from tracking.

All of this functionality is native within SharePoint -- RSS feeds can be generated on virtually any content, Search Alerts can be extremely powerful, especially when customized and recommended to users based on perceived audience type, and the "My Links" functionality can be re-branded as needed.  Additional collections can be created as part of a default My Site template.

 

Broadcasting information is a relatively simple concept, but an important way to empower individuals to share and document tribal knowledge, and spread relevant information to their peers. 

  • Blogs
  • Microblogging

Blogs are native within SharePoint Server and can be enhanced with various community tools.  Microblogging can be implemented in a variety of ways -- Integration with Office Communicator, Twitter and Yammer are all becoming more popular.  Twitter and Yammer have such robust service models that they can be integrated to with nothing but SharePoint Designer and Data Views.

 

Circle of Connections or the concept of creating a network of other people, in which attributes can define differences in the types of relations, are critical to successful collaboration and broader awareness in the organization.  SharePoint natively provides some loose colleague information based on user profiles -- But this can be vastly enhanced with small customizations.  Basic search queries can be used to recommend relevant people to the user while browsing the site based on any attributes in the profile.  A user can be prompted to add a user as a connection by simply inserting a row into a custom connections list in a My Site.  This topic alone merits a long article and we'll dive into it in the near future.

 

Presence is a simple, and native feature of SharePoint, which shows when a user is online, and how they can be contacted.  If surfaced intelligently within the interface it can greatly ease the communication between users.   For example, a user may find a document and see immediately the author of the document is online and available for chat or a phone call with a single click.  Questions can be answered immediately and lost time is drastically reduced.

 

Integration is perhaps one of the easiest ways to quickly drive usage of a portal.  Every large organization is powered by a web of line of business applications ranging from CRM systems to accounting systems, HR systems to product databases.  In many cases only specific users have access to data in many systems.  Simply leveraging SharePoint's Business Data Catalog to pull this data into Search, dashboard pages, and mashups for users can allow access to vital information that otherwise would be unavailable and reduce the workload on those individuals who have traditionally had access to the systems.  A byproduct of this is often a savings in license costs due to a reduce need to purchase client applications for line of business systems.

 

Measuring Success

Finishing implementation of an Enterprise 2.0 project is only the beginning of a long journey towards success.  We have to gain user adoption, create efficiencies, and in the longer term, have a definitive return on investment.  I stated earlier our goal was to "increase productivity through awareness of the responsibilities and goals of others" -- So how can we measure if we have increased this awareness and what effect it has had?

 

There are a combination of hard and soft metrics we can track and analyze:

  • Portal Traffic 
  • User ratings on content
  • Search logs and the perceived relevancy of results
  • Collecting behavior -- Quantities and usage of subscriptions/alerts/favorites
  • Traversal of networks -- If implemented, the frequency of users finding content by traversing recommended networks of users and departments.
  • Interviews and Surveys to measure user satisfaction and awareness
Tags: , , , , Comments (3) | Permalink
Virtual Earth Map in SharePoint Search Results
16. March 2009 09:15

I often integrate Virtual Earth / Live Maps into MOSS because It's a relatively easy way to add some interesting and useful interaction without any custom code.

I wanted to share with you the 'default' XSL template I typically start from for generating a Virtual Earth Map in my MOSS search results.  From here, I make whatever enhancements or customizations I want, which I'll describe more in a moment.

The prerequisites here are that you have managed columns with Latitude and Longitude that are coming back in your search results (which means you've updated the columns XML to include them on the settings of your search core results webpart)

Here's an example of the managed columns I've got, and will be using -- It's simply an addition of Lat and Lon, and utilization of the existing Title column.  On the right is my updated XML that goes in the columns property of the core results part:

image image

This data could come from a BDC connection to an external data source (e.g. SQL), or you could have a content type or list that has the Lat/Lon information in it.

(If you have a big list or table of data with addresses, and want to generate the coordinates for them, I recommend using this tool: http://www.batchgeocode.com/, You can export your list to excel, save as a delimited format, geocode, and re-import)

So once you have your columns available, this is the base XSL you can put in your core results part to generate a map, and put Push Pins with a popup for the Title at all the correct locations:

 

maptransform.xsl (2.34 kb)

 

The XSL does the following:

  1. Create a div for the map
  2. Includes the Virtual Earth javascript
  3. Write javascript for creating the map, creating a shape array, and pushing the CreateMap function into the body load for sharepoint (_spBodyOnLoadFunctionNames)
  4. Use the XSL to generate a bunch of calls to "Add Shape" based on the search results, to add in all the points.  You could expand this to add any HTML into the pushpin popup, such as content from the result item.

 

You will need to update the Map.LoadMap call to set the zoom level and coordinates to center on (currently its in Redmond, Washington, at a high zoom).

You can build on this using the ability to drag areas of the map to refine search results, or use the built in clustering ability to cluster large groups at different zoom levels.

Good luck!

Tags: , , , , Comments (2) | Permalink
SharePoint ULS Log Viewer 2.0 Released
10. March 2009 08:44

I've been a bit quiet on the blog lately as I've been trying to finish up several exciting things.  One of them is an updated version of the SharePoint ULS Log Viewer.

The original post about the ULSViewer.

The key benefit of using the viewer is that you do *not* need access to the SharePoint server.  Great for when clients send log files.

The new version has some really simple but useful new features:

  • Sort on any column by clicking column header (ascending or descending)
  • Ability to open and concatenate multiple log files (select multiple from open dialog)
  • Ability to automatically browse the default log directory (When running on a SharePoint server)
  • Full Text Search (of log Message, Category, and Process AND combined with other filters)

image

You can Download It Here from CodePlex

Tags: , , , Comments (0) | Permalink
Displaying 'Person' Columns with Presence in a Data View
27. January 2009 15:21

(The title of this post could also be: "How to disable output escaping of the columns in your SharePoint Data View from SharePoint Designer")

You may have tried to use a list with a Person column as the source for a Data View.  You may have even had Presence information available in that column.

It's likely that all you got was a bunch of garbled HTML when you actually rendered the column.  This is because by default, the XSL transformation will escape all the HTML characters rendered for the "People" column type.  With a simple attribute in your XSL you can fix this, and show single and multiple Person entries correctly.

If you look in your code view in SharePoint Designer where the column is rendered, you'll see a simple value-of select like this:

<xsl:value-of select="@People" />


Simply modify that by adding an output escaping attribute:



<xsl:value-of select="@People" disable-output-escaping="yes" />


And now it should render the column properly.  This will work for any data type that contains HTML.

Tags: , , , Comments (2) | Permalink