Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top