0

For a SharePoint 2010 environment, I am trying to use Visual Studio to creating custom columns, a content type, a custom document library template based on the content type, and an instance of the template.

For the most part, the objects are being created (the columns, content type, template, and instance), yet it does not look like some field properties set via attributes in the xml file are being set.

Most notable, the ReadOnly and ShowInXXXForm properties. My guess is that I have something missing in the config someplace but I cannot seem to find it. Here is the code

Elements.xml for the Site Column

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Field
        ID="{f41f6d8e-ca33-4867-af14-adedba9b0eb1}"
        Name="KnowledgeBaseArticleStatus"
        DisplayName="Publishing Status"
        Type="Text"
        Required="false"
        Group="Knowledge Base Articles"
        ShowInEditForm="false"
        ShowInNewForm="false"
        >
    </Field>
</Elements>

Elements.xml snippet for Content Type

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <!-- Parent ContentType: Document (0x0101) -->
    <ContentType ID="0x010100E28D2FB8531146D582E6FC3729433EFF"
                 Name="KB Article"
                 Group="$Resources:core,Document_Content_Types;"
                 Description="KB Articles Content Type"
                 Inherits="TRUE"
                 Version="0">
        <FieldRefs>
            <FieldRef ID="{f41f6d8e-ca33-4867-af14-adedba9b0eb1}"
                      Name="KnowledgeBaseArticleStatus" />
            ...
            ...
        </FieldRefs>
    </ContentType>
</Elements>

Schema.xml snippet for List Template

<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint"
      Title="KnowledgeBaseArticlesTemplate"
      Direction="$Resources:Direction;"
      Url="KnowledgeBaseArticlesTemplate"
      BaseType="1"
      xmlns="http://schemas.microsoft.com/sharepoint/"
      EnableContentTypes="TRUE">
    <MetaData>
        <ContentTypes>
            <ContentType ID="0x010100E28D2FB8531146D582E6FC3729433EFF"
                         Name="KB Article"
                         Group="$Resources:core,Document_Content_Types;"
                         Description="KB Articles Content Type"
                         Inherits="TRUE"
                         Version="0">
                <FieldRefs>
                    <FieldRef ID="{f41f6d8e-ca33-4867-af14-adedba9b0eb1}" />
                    ...
                    ...
                </FieldRefs>
            </ContentType>
        </ContentTypes>
        <Fields>
            ...
            ...
            <Field ID="{f41f6d8e-ca33-4867-af14-adedba9b0eb1}"
                   Name="KnowledgeBaseArticleStatus"
                   DisplayName="Publishing Status"
                   Type="Text"
                   Required="false"
                   ShowInEditForm="false"
                   ShowInNewForm="false"
                   Group="Knowledge Base Articles"></Field>
            ...
            ...
        </Fields>
            ...
            ...
    </MetaData>
</List>

The end result is that both the Display Form and Edit Form show the field whereas I only want the Display Form to render it. I have tried playing around with different combinations of ReadOnly="true|false" and ShowInXXXForm="true|false" to no avail.

I have also used SharePoint Manager 2013 to look at the properties of all the objects.

While some properties seem to be set, for example Group, the others are not. I also looked at the Schema Xml tab in that utility, and for the fields defined under Site Columns and Content Type, the xml value matches what I had in the deployment yet for the list instance (based on the template) it does not. (I am not sure if there is a correlation between that value and what I deploy.)

For example, using SharePoint Manager I see the following Schema Xml value

<Field ID="{f41f6d8e-ca33-4867-af14-adedba9b0eb1}" Name="KnowledgeBaseArticleStatus" DisplayName="Publishing Status" Type="Text" Required="false" AllowDeletion="false" Group="Knowledge Base Articles" ReadOnly="true" ShowInEditForm="false" ColName="nvarchar10" StaticName="KnowledgeBaseArticleStatus" SourceID="{DA5DD67A-35ED-4D3F-89BC-8F8C5F9B33BF}" />

And the following property values (or lack off...)

enter image description here

Edit -- Additional Info

Thank you @Cann0nF0dder. Using uppercase seems to fix the problem of properties being applied. Oddly enough, according to VS intellisense multiple cases should be acceptable but that does not seem to be the truth.

enter image description here

However, I still do not see the properties set via SharePoint Manager (see image above) and the Schema XML does not match so I am not sure where/how the xml is being applied. Any insight to that?

  • 3
    Don't know without looking my code, but is it something as simple as setting value to False or FALSE instead of false. I swear I've had issues using the wrong case in the past. Might not been those properties though. – Cann0nF0dder Jan 28 '14 at 18:43
  • I got the same idea as @Cann0nF0dder popping up in my head. Sometimes the XML is sensitive to casing. – Robert Lindgren Jan 28 '14 at 18:58
  • Sorry @Jason, I don't really use SharePoint Manager. Are your columns still showing in the forms? Although SharePoint Manager is a codeplex tool, and can be useful, it is a 3rd party tool, therefore I wouldn't worry too much if your code is working, but a property not showing in SharePoint Manager. – Cann0nF0dder Jan 29 '14 at 9:57
  • @Cann0nF0dder The forms are working when using uppercase TRUE|FALSE values. Odd thing about SharePoint Manager is that it is using the SP object model to display its data. And if I use it to set a property, it is reflected in the browser. Obviously there is some sort of disconnect/difference when setting column/list/site/etc properties via the API and object model and when using XML and deployed features. – Jason Jan 29 '14 at 19:09
  • @Cann0nF0dder - Do you want to retype your comment as the question answer so I can mark it and give you credit? – Jason Feb 4 '14 at 22:22
0

Jason, Thank you. I've re-written my initial comment as an answer. It should be something as simple as setting value to False or FALSE instead of false.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.