SharePoint Dragons

Nikander & Margriet on SharePoint

Category Archives: Uncategorized

SharePoint 2010: Problem Adding Term Sets with ‘&’ in their name

We were working on a PowerShell script that reads an XML file and uses that as the basis for adding new terms to SharePoint. Some of the term names in XML contained & which eventually gets replaced by the ampersand (&) character. Now, something strange happens, SharePoint converts this to the 65286 character (or 0xFF06 in Hex). This is an ampersand (&) character, but not the same as the normal ampersand (&) 38 character. But, PowerShell converts the ampersand (&) character to the normal 38 character, and then you’re in limbo land. What happens is this:

  1. We check if a term exists.
  2. If it’s not, we add it.
  3. We commit all changes.

Once we were committing, an error occurs stating that we were trying to add a term that already exists. Why is that happening?

  1. In PowerShell, we check for a term that contains & (= char 38). It’s not present in the SharePoint term store, there’s just the term containing & (= char 65286).
  2. We add a new term containing char 38.
  3. SharePoint converts char 38 to char 65286, but that one is already present.
  4. An error occurs.

This problem took some time to diagnose, the solution is simpler. Make sure the index name you’re using contains char 65286, instead of char 38. In PowerShell, the code looks like this:

#Please Note:
# This is a tricky piece of code, as SharePoint converts & to a special & sign (char 65286 or 0xff06 in HEX).
# Within PS, this special & sign gets converted and equals the normal & sign (char 38).
# Therefore, a normal equality test of a string in PS NEVER matches the Terms index name in SharePoint,
# because & (value 65286) is not identical to & (value 38)
#
# To solve this issue, & (38) needs to be replaced by & (65286)           

$IndexName = $TermNode.Name.Replace(([char] 38), ([char] 0xff06))
$Term = $Termsetitem.Terms[$IndexName]

We must have won the lottery, because by mistake we also included term names containing two consecutive spaces. SharePoint tries to help out by replacing them with a single space. Now this happens:

  1. We check for a term that contains double spaces.
  2. The term store only has a term with single spaces, so the new term is added.
  3. SharePoint converts double spaces to a single space, adds the term, but that one is already present.
  4. An error occurs.

We could do another replace, but decided that this is more of a configuration mistake. So, we’re not handling that one in code, but fixed the XML config file and then things worked like a charm.

The final question is this: is SharePoint right in replacing double consecutive spaces to a single one?  We decided the answer is no. Fixing term spelling makes the mechanism unpredictable and arbitrary (since SharePoint only seems to care about & and double spaces). Besides, it’s not SharePoint that has to decide on the name, it’s the term store administrator/end user who needs to decide. It reminds us of years ago. We were writing a technical design document and correcting the spelling of business terms that were used in a functional document written by the customer. At that time, we had a mentor who said: “Leave it be, you may not agree, but it’s the customer who decides on the business terms”. We thought this was a wise advise.

Cross-origin communication

The JavaScript window.postmessage seems to be just what we were looking for when looking for a mechanism for SharePoint Apps to talk to each other: https://developer.mozilla.org/en-US/docs/DOM/window.postMessage

The Super Secret Wiki Ninja Secret

Margriet’s Wiki Ninja post called “The Super Secret Wiki Ninja Secret” can be found here: http://blogs.technet.com/b/wikininjas/archive/2013/01/20/the-super-secret-wiki-ninja-secret.aspx

Top 10 SharePoint Blogs

From now on, we’re going to do the SharePoint 10 blogs differently. We’re going to do it once every 3 months and try to get more community participation. In +/- 2 weeks a Sticky Thread will appear in the SharePoint forums where people can vote on the Top 10 blogs. This voting process will be repeated quarterly. The top 10 will be placed on the popular TechNet Wiki SharePoint 2013 Best Practices page and will appear on the TechNet Wiki Ninja Blog Spot.

Working with .BLG files

When doing performance analysis, we routinely record .blg files using perfmon to inspect the various servers involved in the SharePoint farm. We were looking for a library or piece of .NET code to read such .blg files but eventually came to the conclusion that there are only two workable solutions:

$result = import-counter .\sample.blg
$result | export-counter -path .\output.csv -FileFormat csv

For more info on SharePoint related perf counters and the related get-counter cmd, check out http://gallery.technet.microsoft.com/PowerShell-script-for-59cf3f70

SharePoint 2013 Feature Overview

And another SharePoint 2013 feature comparison overview: http://www.apps4rent.com/sharepoint-2013-features-comparison.html

It’s the SharePoint Flavored Weblog Reader again!

 

We’ve released SFWR v1.3.

What is it?

“The IIS logs are an invaluable way to get to know your web application and your end users once it’s in production. Therefore, having a tool to analyze IIS logs is in invaluable asset in your bag of tricks. Especially if this tool has a certain SharePoint flavor added to it…”

What’s the update?

“Not everybody has the same IIS logging settings, that’s why SFWR uses the DLR to support this. Nevertheless, there were certain reports that threw exceptions and caused processing to halt because they expect certain data to be present (mainly bytes sent and bytes received). v1.3 uses a little Aspect Oriented Programming (AOP) to make sure all report calculation errors are handled.”

Where to  get it?

http://gallery.technet.microsoft.com/The-SharePoint-Flavored-5b03f323

GhostDoc – Way of the Samurai

Or was that movie called Ghostdog? Anyway, we haven’t looked at this tool for years, and retried it again recently: GhostDoc. If you don’t know it, take a look at it ( http://submain.com/products/ghostdoc.aspx ). It’s a nice tool for auto generating comments. The reason we didn’t like it that much originally, was because we didn’t think the auto generated comments were very helpful. Check out this example and you know what we mean:

/// <summary>
/// Gets or sets the delay in seconds.
/// </summary>
/// <value>
/// The delay in seconds.
/// </value>
public int DelayInSeconds { get; set; }

The reason we fell in love with it this time is because pressing CTRL+A (to select everything, a standard shortcut) followed by CTRL+SHIFT+D (GhostDoc specific) sets up a nice start that allows you to fill in missing information and make the comments more valuable, while saving a lot of keystrokes. On second view, this tool is actually quite handy!

PressurePoint Dragon for SharePoint 2013

When you apply enough pressure, every application you or somebody else builds has a point where it breaks. I call this point the pressure point. PressurePoint Dragon for SharePoint 2013 will help you find this point, the follow-up of the generic PressurePoint tool: http://gallery.technet.microsoft.com/PressurePoint-Dragon-for-87572ee1

CAML Designer 2013