Custom Field fails to Show in Custom Content Type

This has to be one of the weirdest things I’ve seen for ages – and there are a few weird things in SharePoint believe me.

I was trying to add a Custom Field to a Custom Content Type -I’ve done this many time before.  But no matter what I did I couldn’t get the Field to show.  Because the Custom Field was based upon a Custom Field Type, I naturally assumed the problem was mine and I had somehow missed out some bit of configuration.  But no, no problem of mine it turns out.  Here’s my XML code.

<xml version="1.0" encoding="utf-8"?>
<Elements xmlns="">
<!-- Our own Site Field of our Custom Field Type -->
<Field ID="{8289B499-E2AE-48C2-80EA-8E9F52EB9542}"
DisplayName="Session Rating"
SourceID="" />
<!-- Our Own Custom ContentType based on Event (0x02) which uses our 'SessionRating' Field -->
<ContentType ID="0x010200dc3e7098a5ab4ee6a7597e5177c2b56e"
Name="NxtGenUG Event"
Description="NxtGenUG Rated Session"
<!-- This is my Custom Field -->
<FieldRef ID="{8289B499-E2AE-48C2-80EA-8E9F52EB9542}" Name="SessionRating" DisplayName="Session Rating" Required="FALSE" />

Can you spot the problem? Nope neither could I.  For ages. There is in fact absolutely nothing wrong with the XML, apart from the XML comment above the <FieldRef> tag.  Yep.  Pretty unbelievable but removing the comment actually resolved the issue. WTF?!

I guess the chap or chapess who wrote that bit of XML parsing code was only looking for the next nodes after the node and not properly selecting all of the nodes. So don’t try to be good and comment your nodes, it will make your fields disappear. Doh!


Dave Mc


About davemcmahon81
Software Developer & Architect, User Group Leader, Speaker, Writer, Blogger, Occasional Guitarist, Man-made Global Warming Sceptic, Climate Change Believer, General Optimist but most of all proud Husband and Dad ...

One Response to Custom Field fails to Show in Custom Content Type

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: