Nick Hadlee's Blog on SharePoint and Other Occasional Rants…


SharePoint Conference and 2010
August 24, 2009, 8:05 pm
Filed under: 2010, SharePoint

I’m pretty excited about attending the SharePoint Conference in Las Vegas (not to mention fortunate).

A quick check online reports the distance between New Zealand and California is over 10,750 kilometers (6,700 miles). There is a bit of a margin for error as the online tools didn’t know about Christchurch, but needless to say its a long way.

Microsoft recently launched a shiny new website for the conference with all the usual pre-conference information:

Sharepoint Conference

So whats on the agenda? According to the session sneak peak:

  • SharePoint 2010 Overview and What’s New
  • Upgrading to SharePoint 2010
  • SharePoint 2010 Capacity and Performance Planning
  • SharePoint 2010 Security and Identity Management: What’s New.
  • Visual Studio 2010 Tools for Office Development
  • SharePoint 2010 Ribbon, ECMAScript and Dialog Framework Development
  • Developing with REST and LINQ in SharePoint 2010
  • Upgrading SharePoint Server 2007 Code to SharePoint 2010
  • Building SharePoint Composite Applications with the Microsoft Application Platform
  • What’s New in Business Connectivity Services (The Business Data Catalog Evolves!)
  • FAST Search for SharePoint – Capabilities Deep-Dive
  • Advanced Dashboard Creation with PerformancePoint Services for SharePoint 2010
  • Overview of Visio 2010 and Visio Services for SharePoint 2010
  • SharePoint 2010 Web Content Management Deep-Dive
  • If You Build It, They Will Come: Driving End User Adoption

Are you attending #spc10? If so drop me a comment or a tweet as I hope to meet as many SharePoint people as possible while in the US of A!



jQuery to Fix ‘Image Web Part’
July 18, 2009, 6:35 pm
Filed under: jQuery, SharePoint

While working on a mini-demo site today I managed to get distracted with a very minor (and irrelevant) component of the site. I felt compelled to find an elegant-ish resolution even though it served no practical purpose for the demo I was building. How often does that happen?

Image Web Part Sizing

The out-of-the-box Image Web Part is great for adding images to a site. Like all Web Parts it has some properties for changing the web parts behavior, but the problem is some of them don’t quite work as you might expect.

The width and height properties are the true target of this this post. Your initial expectation when you set them is the image displayed by the web part will resize to match the settings. This just isn’t how it works – if the image’s physical size is bigger than the Web Part then some ugly scroll-bars appear.

Image Without Resize

Figure 1: Standard ‘Image Web Part’ with the width property set.

Using a little bit of jQuery we can use these properties to apply the settings to our image as well. The following script can be added to the site using the Content Editor Web Part.

 <script type="text/javascript">
$(function(){
 $("img[id^='MSOImageWebPart_']").each(function(){
            var width = $(this).width();
            var parentDiv = $(this).parents("div.ms-WPBody");
            if(width > parentDiv.width()) {
                this.width = parentDiv.width();
            }
        });       
});
</script>  

Dynamically Resized Image

Figure 2: ‘Image Web Part’ that was resized with jQuery

Note: In this example I am only manipulating the width property of the image element. This leaves the browser to calculate the height of the image to keep everything in proportion. The height could be applied as well but then the image can start to look a little distorted):

See my previous post on jQuerywhich has some useful jQuery links including Jan Tielens excellent post on deploying jQuery to a site collection via a feature. Time to get back to building the demo now the distraction has been dealt with…



Search Service, Anonymous Access and 401s
July 7, 2009, 11:26 pm
Filed under: Administration, Authentication, SharePoint

In another semi-related post I was talking about anonymous access in SharePoint and a work around that can be used if you need to force authentication to work at the same time. It is as counter intuitive as it sounds…

An unexpected side affect of anonymous access can be that SharePoint web services might not work as expected. This certainly was the case in the situation I described in the other post but luckily Dave Wollerman describes a fix for this issue.

An issue I can see arising is when you start to disconnect what SharePoint is managing – configurations via central administration – versus what you are now directly responsible for managing with IIS then your maintenance headache increases. For example: In a farm you will need to make sure all front-ends are synchronised by changing the IIS settings on each server.



Anonymous Access, Windows Authentication and ‘Forcing’ an Automatic Sign In
July 7, 2009, 10:35 pm
Filed under: Authentication, SharePoint

If for what ever reason (read disclaimer at end) you need anonymous access enabled on a SharePoint site that is using windows authentication, you will notice that even as an authorised user you are not signed in automatically. The anonymous ‘experience’ will always take precedence over the users credentials [1]. This is the way the HTTP protocol works so IIS and SharePoint are off the hook for this issue.

If you do want to be a recognised user then you will  need to click on the ‘Sign In’ link at the top of the site. Depending on your browser security settings you will either be signed in automatically or prompted for credentials. 

Solution

This is less of a solution and more of a work around but it will achieve the desired result. To force an auto-sign in under SharePoint you need a page that has unique permissionsto force the challenge/response for credentials. This can then be provided to the authenticated users as the ‘authenticated’ homepage url.

There are a few limitions with this method:

  • Anonymous users will not be able to access this page
  • To be more useful the page will probably need some redirection, i.e. To pass the user back to a global home page, and this provides its own set of challenges
  • Unless the authenticated user hit this page first, i.e. They follow direct links to somewhere else in the site, they will not be signed in 

Disclaimer: This was a work around to an issue I recently had to face because anonymous users and authenticated users needed to access SharePoint via the same url. There are much better ways to provide multiple authentication methods which are recommended as the preferred option.

References: [1] To be completely safe I confirmed this behavior is expected with Paul Stork at his ‘Anonymous Access: Everything you always wanted to know, but didn’t know to ask’ session while at the New Zealand SharePoint Conference.



Custom ASPX forms for SharePoint Workflows Part 1
June 27, 2009, 12:34 pm
Filed under: Cutomisation, Development, SharePoint, Workflow

Recently I needed to build a relatively simple notification workflow that included a custom form when the workflow was initially added to a list. In SharePoint workflow terminology, this is called an association form.

Super Quick Forms Overview

This is from the Workflow Forms Overview on MSDN. “[Forms] enable you to make your workflows more dynamic and flexible. Forms enable you to gather information from users at predefined times in the workflow’s life, as well as let users interact with the tasks for that workflow.” That all sounds great so what next?

If you are using MOSS then there are two options; InfoPath or ASP.NET (ASPX forms from now on). If you are using WSS then there is only one option; ASP.NET.

The difference between the two options is the amount of complexity involved to get them working and the level of flexibility each option provides. InfoPath forms are easier to implement but much less flexible. ASPX forms are much harder to implement but provide all the flexibility and robustness of the .NET framework.

Online Help for ASPX Forms Development

Perhaps it is just my search skills but I could find very little good information about how to implement the ASPX forms via the official channels. On MSDN there is a How to: Implement a SharePoint Workflow with ASP.NET Forms article which describes itself as a “high-level description” and also the Developer Introduction to Workflows for Windows SharePoint Services 3.0 and SharePoint Server 2007. A post on the SharePoint Team blog provides some other good overview material but it is still a little light on detail.

With a bit more searching I came across Serge Luca’s 15 part tutorials on workflow – these are not just on ASPX forms but provide examples about all sorts of workflow development tasks. Step 9, step 14 and step 15 are the posts specifically about ASPX forms. Serge’s examples are based on the Collect Feedback Workflow project which is part of the Office SDK (I came across a post by Andy Burns saying they had taken it out of the SDK so he has a link to a version in his post if you need it). Beware that the SDK project has a few bugs in it that need to be fixed.

Serge has also done a series of presentations on Microsoft Belux (a Belgium MSDN resource? I think the homepage is in Flemish but Serge’s presentations are all in English) that map closely to his series of posts.

In part 2 I will describe the notification workflow that I built and post some code examples including the bug fixes needed for the SDK workflow project.



Mostly Free Screencasts
May 31, 2009, 1:41 pm
Filed under: SharePoint, Training

This looks like a great free resource for some SharePoint screencasts. Some of the content is subscriber only but there is heaps that isn’t, I haven’t checked them out yet but intend to.

I usually add all the useful resources I find to a knowledge base of helpful SharePoint links. Do you know of any other good online resources?



When an Index Server Can’t Stop ‘Stopping’
May 27, 2009, 11:10 pm
Filed under: Administration, SharePoint, SQL, Troubleshooting

Due to some erratic behavior with a farms index server it was necessary to uninstall the indexing role and then re-provision it. The problem was during the uninstall the index service got stuck in a stopping state. A quick check in the error logs pointed to the SQL server. The SQL server logs were a little more descriptive with a 17310 event and even included the words ‘fatal’:

Event Type:    Error
Event Source:    MSSQLSERVER
Event Category:    (2)
Event ID:    17310
Date:        M/dd/yyyy
Time:        h:mm:ss yy
User:        N/A
Computer:    xxxx
Description: A user request from the session with SPID XXX generated a fatal exception. SQLServer is terminating this session. Contact Product Support Services with the dump produced in the log directory.

I have found when troubleshooting Google can either be a savior or a massive run-around, usually it depends on the reliability of the source and how good your searching skills are. In this situation what appeared to be a Chernobyl-esq problem had been encountered by a few people and ensuring that service pack 2 was installed on the SQL Server was the recommended fix. After applying the service pack the SQL logs were clear and the index service was able to be uninstalled and re-provisioned.

Unresolved Questions

The biggest question in the aftermath was why was a production SQL server not running the latest service packs? Surely someone has neglected their duties?

The infrastructure guy responsible for the SQL server has an interesting theory, especially if you like the implausible, the current blame for this issue was the installation of the SQL business intelligence studio onto the server which downgraded the SQL dll’s back to the RTM version. This will make a interesting test and would represent a massive bug if it was the case. Has anyone come across this or something similar before? It wouldn’t be the first software bug and it won’t be the last…



Service Pack 2 and SharePoint Kaboom!
May 23, 2009, 2:26 pm
Filed under: SharePoint

It looks like the SharePoint team have accidentally introduced a small bug into SharePoint with the release of service pack 2. Basically if you installed service pack 2 your SharePoint installation is on a 180 day countdown to expiry. Seriously!

Sometimes it is good not to be an early adopter…

Read more about it and the fix at the SharePoint Team Blog.



Customise Breadcrumbs with jQuery the SharePoint Swiss-Army Knife
May 23, 2009, 2:22 pm
Filed under: Development, jQuery, SharePoint, WCM

Breadcrumbs in SharePoint seem to be a pet hate for many people, but they are a necessary evil as they provide a fundamental part of the SharePoint navigation. The stock standard SiteMapProvider SPContentMapProvider is good from within libraries and lists but is lousy for pages as described by Heather Solomon:

The main issue with the WSS site map provider is it will show directories you don’t want it to (mainly the Pages library) in the breadcrumb, and on some pages it will show ".aspx" on the end of the page name. The MOSS site map provider is more graceful, it just doesn’t show the list or library name in the breadcrumb.

So using the WSS breadcrumb we would get the following breadcrumb from within a library or list:

Site Name > Library or List Name > Folder Name

That is pretty useful for users, especially if they have a habit (I’m tempted to say bad habit!) of using folders to manage their content. The problem is what you see when viewing a page:

Site Name > Pages > PageName.aspx

What we really want to see is a very stripped down breadcrumb more like what the CurrentNavSiteMapProviderNoEncode provides:

Site Name

The best approach is to modify the relevant page layouts so we are using the CurrentNavSiteMapProviderNoEncode for our page level breadcrumbs. Then we have the SPContentMapProvider in the master page as the default breadcrumb provider and the nicer page level breadcrumb coming from CurrentNavSiteMapProviderNoEncode. The problem is what if we have lots of page layouts or even worse we don’t have any page layouts at our disposal – WSS or non publishing MOSS sites? Using a bit of jQuery we can mimic what the we could get with the CurrentNavSiteMapProviderNoEncode by using only the SPContentMapProvider breadcrumbs:

That might not be optimal jQuery (in fact I could almost guarantee its not so if anybody can suggest optimisations please let me know!) and this solution is not going to be very useful unless you can deploy it into your entire site via a web or site scoped feature. Jan Tielens provides a really good example on how to integrate jQuery into SharePoint using the AdditionalPageHead delegate control.

$(document).ready(function() {
	var pageIndex = -1;
	var offset = 2;
	var $spans = $("#ctl00_PlaceHolderTitleBreadcrumb_ContentMap > span");

	if($spans.eq($spans.length - 1).text().search(/\.aspx$/) > -1) {
		$spans.each(function(i) {
			if( $(this).text() == "Pages" ) {
				pageIndex = i;	
			}
		});	

		$spans.each(function(i) {
			if(i == (pageIndex - offset)) {
				$(this).addClass("ms-sitemapdirectional");
				var innerText = $(this).text();		
				$(this).empty();	
				$(this).text(innerText);
			} else if((pageIndex != -1) && (i > (pageIndex - offset))) {
				$(this).empty();
			}
		});
	}
});

Want to know more about jQuery? A simple google search on jQuery+SharePoint is a good start or take a look at what Jan Tielens or the guys and gals at End User SharePoint have got to say.



My SharePoint Saturday 16-05-09
May 16, 2009, 11:34 am
Filed under: Development, Search, SharePoint, WCM

I have so many posts in draft status and nothing ever getting published, therefore this is the super-quick-two-things-to-check-up-on-later post. As usual, at least of of late, the most interesting content I am finding is coming from twitter tweets. This just goes to show Joel Oleson’s post on the SharePoint community which talked about technologies like twitter is a fairly accurate reflection on the current state of things.

Via @harbars: Labs/samples for #SharePoint web content management on http://www.mssharepointdeveloper.com #WCM.

Via @SharePointMVPs: Matthew McDermott’s search session at Tech Ed OFC317 Search Challenges and Tricks

I must really get around to putting up those other posts!

[Updated 17-05-09]

A couple more interesting things from today:

Reza Alirezaei (@rezaal): Working with Structured Data in Microsoft Office SharePoint Server 2007 (Part 4): SharePoint Designer. Includes a nice demo on how to create a master/detail views on data with the incredibly useful Data Form Web Part.

Lars Fastrup: Microsoft SharePoint 2010 news from TechEd US 2009. Includes some interesting observations about new functionality/features in SharePoint 2010, like the office ribbon, gleaned by seeing it in action during some presentations.




%d bloggers like this: