When True!=TRUE and when NOT to listen to your boss while dealing with Content Types

So I’ve struggled with this weird issue for most of the day yesterday and this morning.  The issue is that a new SharePoint custom content type I’m adding to the project I’m working on, was not showing the additional site columns on the forms at all. (Yes, as you’ll notice, some are marked NOT to show on some forms, but one specifically is, and it was not showing at all)

Eric and I exchanged a few emails about it this morning, then double teamed it this morning over IM to get to the bottom of it. (More on the when NOT to listen to your boss bit in a moment, but it was important to listen to him this time Smile)

Let’s start with what the schema for the content type WAS, then I’ll explain what I changed.

Initial Schema

 

<?xml version=”1.0″ encoding=”utf-8″?>
<Elements xmlns=”http://schemas.microsoft.com/sharepoint/”>
  <!– Define fields–>
  <Field ID=”{9EE866A5-34D6-403A-870E-D058441426DE}”
         Name=”M_UserAssignment”
         DisplayName=”User Assignment Form Link”
         Group=”My Project Site Columns”
         Type=”URL”
         DisplaceOnUpgrade=”True”
         Required=”False”
         Format=”Hyperlink” />
  <Field ID=”{29E5151C-83C6-4FFF-980C-BAC76EC20665}” Name=”M_RequestingUser”
         DisplayName=”Requesting User”
         Group=”My Project Site Columns”
         Type=”Text”
         DisplaceOnUpgrade=”True”
         Required=”False”
         MaxLength=”255″ />
  <Field ID=”{9A4B573E-BE14-4E8B-8F12-71C441116BA4}” Name=”M_PermissionedDocuments”
         DisplayName=”Permissioned Documents”
         Group=”My Project Site Columns”
         Type=”Text”
         DisplaceOnUpgrade=”True”
         Required=”False”
         MaxLength=”255″ />
  <!– Parent ContentType: Task (0x0108) –>
  <ContentType ID=”0x0108008fc7a1218d6d4a48a89adc4c2d4e3fa7″
               Name=”Document Assignment Task”
               Group=”My Project Content Types”
               Description=”Task used to track Document Assignments” 
               Version=”0″>
    <FieldRefs>
      <FieldRef ID=”{29E5151C-83C6-4FFF-980C-BAC76EC20665}”
                Name=”M_RequestingUser”
                DisplayName=”Requesting User”
                Required=”False”
                ShowInDisplayForm=”True”
                ShowInEditForm=”True”
                ShowInNewForm=”True” />
      <FieldRef ID=”{9EE866A5-34D6-403A-870E-D058441426DE}”
                Name=”M_UserAssignment”
                DisplayName=”User Assignment Form Link”
                Required=”False”
                ShowInDisplayForm=”True”
                ShowInEditForm=”False”
                ShowInNewForm=”False” />
      <FieldRef ID=”{9A4B573E-BE14-4E8B-8F12-71C441116BA4}”
                Name=”M_PermissionedDocuments”
                DisplayName=”Permissioned Documents”
                Required=”False”
                ShowInDisplayForm=”False”
                ShowInEditForm=”False”
                ShowInNewForm=”False” />
    </FieldRefs>
  </ContentType>
</Elements>

The were actually two issues with the above schema

  1. True != TRUE.  I’ve used “True” (mixcased) before for certain attributes but it never seemed to matter, but if memory serves me well someone mentioned to me before to just always use the Uppercase version “TRUE” no matter what as there were inconsistencies in how SharePoint interprets it in various places.  Oh well, lesson learned again. Oh, and I made instances of FALSE all upper case as well.
  2. Although this worked for Eric, it didn’t work for me 100%.  For me, I also had to insure that the Inherits attribute was set on the Content Type.  I should NOT have had to do it, since the documentation here clearly states:  “If Inherits is FALSE or absent and the parent content type is a built-in type, the child content type inherits only the fields that were in the parent content type when SharePoint Foundation was installed. The child content type does not have any fields that users have added to the parent content type.”  Well, my parent type WAS a built in type…The Task type.  And surely without it, it had the base Task fields in it, just not the ones I added.  Regardless, once I added it, everything worked like a charm. (Edits highlighted red)

Final Schema

 

<?xml version=”1.0″ encoding=”utf-8″?>
<Elements xmlns=”http://schemas.microsoft.com/sharepoint/”>
  <!– Define fields–>
  <Field ID=”{9EE866A5-34D6-403A-870E-D058441426DE}”
         Name=”M_UserAssignment”
         DisplayName=”User Assignment Form Link”
         Group=”My Project Site Columns”
         Type=”URL”
         DisplaceOnUpgrade=”TRUE
         Required=”FALSE
         Format=”Hyperlink” />
  <Field ID=”{29E5151C-83C6-4FFF-980C-BAC76EC20665}” Name=”M_RequestingUser”
         DisplayName=”Requesting User”
         Group=”My Project Site Columns”
         Type=”Text”
         DisplaceOnUpgrade=”TRUE
         Required=”FALSE
         MaxLength=”255″ />
  <Field ID=”{9A4B573E-BE14-4E8B-8F12-71C441116BA4}” Name=”M_PermissionedDocuments”
         DisplayName=”Permissioned Documents”
         Group=”My Project Site Columns”
         Type=”Text”
         DisplaceOnUpgrade=”TRUE
         Required=”FALSE
         MaxLength=”255″ />
  <!– Parent ContentType: Task (0x0108) –>
  <ContentType ID=”0x0108008fc7a1218d6d4a48a89adc4c2d4e3fa7″
               Name=”Document Assignment Task”
               Group=”My Project Content Types”
               Description=”Task used to track Document Assignments”
               Inherits=”TRUE”
               Version=”0″>
    <FieldRefs>
      <FieldRef ID=”{29E5151C-83C6-4FFF-980C-BAC76EC20665}”
                Name=”M_RequestingUser”
                DisplayName=”Requesting User”
                Required=”FALSE
                ShowInDisplayForm=”TRUE
                ShowInEditForm=”TRUE
                ShowInNewForm=”TRUE” />
      <FieldRef ID=”{9EE866A5-34D6-403A-870E-D058441426DE}”
                Name=”M_UserAssignment”
                DisplayName=”User Assignment Form Link”
                Required=”FALSE
                ShowInDisplayForm=”TRUE
                ShowInEditForm=”FALSE
                ShowInNewForm=”FALSE” />
      <FieldRef ID=”{9A4B573E-BE14-4E8B-8F12-71C441116BA4}”
                Name=”M_PermissionedDocuments”
                DisplayName=”Permissioned Documents”
                Required=”FALSE
                ShowInDisplayForm=”FALSE
                ShowInEditForm=”FALSE
                ShowInNewForm=”FALSE” />
    </FieldRefs>
  </ContentType>
</Elements>

So in this case, it was wise to listen to my boss.  Although I think it’s quite retarded. (Not him, just the fact that you might want to use all uppercase for these attributes Smile).

Oh, and as far as when NOT to listen to your boss?   Well when this little challenge began, he told me to hold off on something we were working on as he was about to check in some code to our source control.  I said sure, it’s time for a coffee break anyways.

Well, I came back and had a coughing fit with a mouth full of coffee, and spewed it all over my keyboard; monitors; desk; etc.  It wasn’t a pretty site.  I tried to turn my head in time, but it just didn’t happen.

Now the left CTRL and Function key on my laptop keyboard seem to be permanently out of commission.  and I can’t use the laptop keyboard to type at all <sigh>.  Now I have to make a choice.

  1. Send it in for repairs (Warranty is out, so that’s going to be a chunk), and not be able to go to my remote office in the afternoon time without taking a spare external keyboard. or…
  2. Order a new laptop.

Quite honestly, I think I’m going to do both.  I want a more powerful laptop, and I can recoup the repair cost by selling the old laptop to a family member Smile.

One thing is for sure.  The next time Eric tells me to go take a coffee break, I’m either going to just stay put, or just STAY AWAY FROM THE KEYBOARD.

HTH

– Keith

One Reply to “When True!=TRUE and when NOT to listen to your boss while dealing with Content Types”

  1. Question for you. Have you ever seen behavior where you have list schema as part of a web template. This list schema defines certain fields to be ShowInNewForm=”FALSE”. Everything works like a charm when you deploy code and create a new site using this web template.

    Then you go and create another site using this web template, and suddenly those fields with ShowInNewForm=”FALSE” are showing in the New form! What/?? This occurred after a FRESH web application and code deployment.

    Any thoughts?

Leave a Reply

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

WordPress.com Logo

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

Facebook photo

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

Connecting to %s

%d bloggers like this: