Awkward SharePoint Link field text

I had a gnarly support call today. One of our customers was using Announcement lists to display news on the homepage of their intranet, and they’ve a thumbnail image they’d set for each item. Then, on the home page, they’ve got a Content Query Web Part using some custom XSL to render those announcements.

However, the Content Query Web Part would only show some of the thumbnail images.Capture

TL;DR – Saving an image field on a ‘New’ form without a descripion saves a different format to after an ‘Edit’, which sets a default even if you don’t change the image field value.

Continue reading “Awkward SharePoint Link field text”

Awkward SharePoint Link field text

UserProfile.GetManagers : “An error was encountered while retrieving the user profile”

I was trying to get the managers of a SharePoint user, and I kept getting the error:

An error was encountered while retrieving the user profile

This was from a custom workflow step in an automatically started workflow. If I ran the workflow manually, it worked – but auto-started workflows failed. Continue reading “UserProfile.GetManagers : “An error was encountered while retrieving the user profile””

UserProfile.GetManagers : “An error was encountered while retrieving the user profile”

Rebasing Absolute URLs in SharePoint

SharePoint has this funny mechanism ‘Alternate Access Maps’. Essentially, this means that the same content can be available via different web applications, which have different URLs.

But what do you do if you’ve an absolute URL to something in SharePoint, and you need it to be correct for the users’s current alternate access map zone?

Well, there is a function SPUtility.AlternateServerUrlFromHttpRequestUrl() – but I couldn’t see how to use it. Internally, it uses RebaseUriWithAlternateUri() – looks promising. And it works.

string url - "Absolute URL in the wrong zone";
SPUrlZone zone = SPContext.Current.Site.Zone;
Uri currentZoneUrl = SPFarm.Local.AlternateUrlCollections.RebaseUriWithAlternateUri(new Uri(url), zone);

I’m a bit suspicious of using the local SPFarm object, but that seems to work correctly. Others do seem to have done this:

Rebasing Absolute URLs in SharePoint

SPUtility.Redirect – to the Layouts directory

I always find myself having to look this stuff up, and it’s nearly always for the same format of redirect, so here’s a reminder for myself. In SharePoint, you can redirect to a page in Layouts (in this case, the site settings page) with:

SPUtility.Redirect("settings.aspx", SPRedirectFlags.Static | SPRedirectFlags.RelativeToLayoutsPage|SPRedirectFlags.UseSource, HttpContext.Current);

This also will redirect to a &source= get parameter if available. It also deals with the HIVE number (/15/) in the URL automatically.


SPUtility.Redirect – to the Layouts directory

Drives used for SQL databases are running out of free space

Nearly all SharePoint farms I look at show the error:

Drives used for SQL databases are running out of free space

However, this seems to happen even on SharePoint farms where there is tonnes of space. It’s always puzzled me, and it results in many customers simply ignoring the warning, ‘cos they can’t figure out why they’re getting it, and having checked the drives they think they’re fine (and they probably are).

Well Zoltan Kovacs has a very good analysis. It’s well worth a read. Continue reading “Drives used for SQL databases are running out of free space”

Drives used for SQL databases are running out of free space

Set Global Nav in CSOM

I’ve been writing a client side object model script to set up some sites, including setting some the navigation settings on the site. Sadly, Microsoft have written SharePoint to involve at least 3 objects in the navigation settings for a site (PublishingWeb, WebNavigationSettings, and SPNavigation. At least. It’s totally effing bonkers.), and those objects don’t work in quite the same way for CSOM. For example, it’s not clear how to set a site to ‘show subsites’ in the global navigation. Continue reading “Set Global Nav in CSOM”

Set Global Nav in CSOM

Creating a Web Application Times Out

I was having a problem creating a new SPWebApplication through Central Admin in SharePoint. It would run for a fair while – longer than I’m used to as this machine seems quite slow – and then I’d be shown the IE ‘timeout’ page within the ‘Create Web App’ iframe. The Web App seemed to have created, including creation of the IIS app pool and site, but they never worked correctly – for example, on different attempts I couldn’t:

  • See the web application’s settings in central admin
  • Create a Site collection
  • Login to a site collection that had created successfully, despite being site collection admin.

Fortunately, I’m not the first person to have seen this. Some folks suggest using PowerShell to provision the web application – which I’m guessing doesn’t suffer IIS timeouts – and others suggest increasing the time outs on the application pool itself. I set:

  • Ping Maximum Response Time
  • Shutdown Time Limit
  • Startup Time Limit

… to 900 (instead of 90), I was able to create and successfully access my new site collection!

Creating a Web Application Times Out