SharePoint Content Type Inheritance

Posted on: December 3, 2017

So here is a gotcha that was discovered at work in the last week…it appears that content types don’t just inherit, they also pass properties back up to their parents! Essentially, I had a content type that was being used for a list. The content type inherited from built-in property types, you know the deal Document from Item type thing. Anyway, there was a request to update the compulsory Title field in the list to be ‘Surname’ instead. Simple enough you would think. Well, it is and it isn’t. If you try to be a good little developer and think that you will update the content type because you might use it again and you will want it to be ‘Surname’ there too, well, you would be wrong. This is what was done, but then ‘Surname’ was popping up all over the place! It turns out that it had sent that edit of the field name back up it’s inheritance and sent them all through the site. The correct way to apply the change is on the List Settings for the specific list where you want to change the Title display name.


Colour Palette

Link | Source
Posted on: December 3, 2017

A site I was working on recently involved applying a new colour theme as part of a rebuild of an existing site. I was given a base colour and was then required to put in place gradients, and various other shades of that colour at points (think :hov etc). I was then asked to change from the colour I was given to another, and then another. I did what any sane person would, and turned to the internet for help. Unfortunately, I found that despite the wealth of easily found tools for creating palettes of complementary colours and converting hex to rgb and a whole manner of things, I could not find what I wanted. All I wanted was to enter a colour, and get increments of that colour that were lighter and darker all the way to white and black.

Given all my searching had failed me, I decided I would have no choice but to implement this tool myself! And actually, what a fun little task to do. Now, I must stress that this was made with the intent of giving me what I needed as quickly as possible. Consequently, it is imperfect, ugly, and perhaps a little inelegant. However, that can all be changed down the line, what it does do though is meet the exact specification of what I needed!

You can view the tool over on Github (code).


SharePoint and Ampersands

Posted on: December 3, 2017

I work with Microsoft SharePoint and have come to know it as a system designed for end users first and developers can ‘work it out!’ That is probably a harsh criticism, I’m sure all developers get annoyed at certain elements of the technology they work with. This is one particular thing that came up and drove me insane until I discovered what was happening.

I was writing a CAML query that included passing in the Title of the page as a parameter, but kept getting no results despite being sure that the query was correct. I could see the fields in SharePoint that should return, but alas the empty set kept coming back. After too long searching I was able to finally find the truth. When adding a Term to the Term Store, if it includes an ampersand (&), SharePoint (in its infinite wisdom) decides to convert that to a wide ampersand (&).

Given my CAML query was taking in a parameter dynamically that included an ampersand on some occasions, I needed to replace these whenever they arose. I had to write a little regex to alter my CAML query before it was executed to substitute in wide ampersands for any regular ampersands. This was essentially:

Regex rgx = new Regex("&");
string text = "My CAML query";
text = rgx.Replace(text, "\uff06");

I find it incredible that the approach taken is to adjust the ampersand in Term Store entries, but not elsewhere on SharePoint (basically begging for this issue to arise), so be aware of the devilish ways of Microsoft and in particular SharePoint!