4

I wanted to create a site template package. Instead of going with a custom site definition, I planned to go with the recommended "Provisioning Provider" technique. The solution was going just fine. created all my features and modules, in the provisioning class I added them to my site one by one and it was working. One I added the module responsible for provisioning the content types, the package stopped working and started receiving the error "Invalid field name {GUID}", whenever I try to create a site collection, where the {GUID} is the GUID of the first field in the content type fields XML tags.

My content types XML is fairly simple:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <!--############################# Start Research Publication Site Columns & Content Type ###############################-->
    <Field  Type="Text" DisplayName="Publication Keywords" Required="TRUE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" Group="Research Publication Columns" ID="{4aa3e7aa-a406-4c5e-b5fe-e6be1736f2ca}"   Name="PublicationKeywords" />
    <Field  Type="HTML" DisplayName="Abstract" RichText="TRUE" RichTextMode="ThemeHtml" Required="TRUE" Group="Research Publication Columns" ID="{fb736a77-13e4-41bc-b760-76b2a56e360e}"   Name="Abstract" />
    <Field  Type="Text" DisplayName="Year" Required="TRUE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" Group="Research Publication Columns" ID="{0dc658e0-6ebb-47f2-b99c-fd2ee5c76887}"   Name="Year" Hidden="FALSE" ReadOnly="FALSE" />
    <Field  Type="Text" DisplayName="ISSN" Required="TRUE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" Group="Research Publication Columns" ID="{27823082-9ffd-4dc5-8a0f-d7096e89ac8b}"   Name="ISSN" />
    <Field  Type="URL"  DisplayName="Website Link" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="Hyperlink" Group="Research Publication Columns" ID="{c9c1c58c-ae91-4c92-b403-c7aacee5bdb1}"   Name="WebsiteLink"  />
    <Field  Type="URL"  DisplayName="Document Link" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="Hyperlink" Group="Research Publication Columns" ID="{5e7a4c4e-e18f-4b7b-9dd1-4d96ee1f8a13}"   Name="DocumentLink" />
    <!-- Research Publication Content Type -->
    <ContentType ID="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D05" Group="Research Content Types" Name="Research Publication" Description="Represents research publications content type." Inherits="TRUE" Version="0">
        <FieldRefs>
            <FieldRef ID="{4aa3e7aa-a406-4c5e-b5fe-e6be1736f2ca}" />
            <FieldRef ID="{fb736a77-13e4-41bc-b760-76b2a56e360e}" />
            <FieldRef ID="{0dc658e0-6ebb-47f2-b99c-fd2ee5c76887}" />
            <FieldRef ID="{27823082-9ffd-4dc5-8a0f-d7096e89ac8b}" />
            <FieldRef ID="{c9c1c58c-ae91-4c92-b403-c7aacee5bdb1}" />
            <FieldRef ID="{5e7a4c4e-e18f-4b7b-9dd1-4d96ee1f8a13}" />
        </FieldRefs>
    </ContentType>
    <!--############################# End Research Publication Site Columns & Content Type ###############################-->


    <!--############################# Start Research Events Site Columns & Content Type ###############################-->
    <Field Type="Text" DisplayName="Event Title" Required="TRUE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" Group="Research Event Columns" ID="{63da83d2-2e0a-4556-8136-8b6a4acdb1bc}" SourceID="{ab60d3a0-898d-46c5-a8c3-797a3c2f6b11}" StaticName="EventTitle" Name="EventTitle" Version="1" Hidden="FALSE" Customization="" ReadOnly="FALSE" PITarget="" PrimaryPITarget="" PIAttribute="" PrimaryPIAttribute="" Aggregation="" Node="" />
    <Field Type="HTML" DisplayName="Event Brief Description" RichText="TRUE" RichTextMode="ThemeHtml" Required="TRUE" Group="Research Event Columns" ID="{4f4fe0d4-a72c-4afe-8585-d7a76c4f15b5}" SourceID="{ab60d3a0-898d-46c5-a8c3-797a3c2f6b11}" StaticName="EventBriefDescription" Name="EventBriefDescription" Description="This Brief Description will show only in the events listing page (landing page)" Version="2" Hidden="FALSE" Customization="" ReadOnly="FALSE" PITarget="" PrimaryPITarget="" PIAttribute="" PrimaryPIAttribute="" Aggregation="" Node="" />
    <Field Type="HTML" DisplayName="Event Details" RichText="TRUE" RichTextMode="ThemeHtml" Required="FALSE" Group="Research Event Columns" ID="{bfe967b8-0ba1-4757-8c5d-d6652719865c}" SourceID="{ab60d3a0-898d-46c5-a8c3-797a3c2f6b11}" StaticName="EventDetails" Name="EventDetails" Customization="" />
    <Field Type="Image" DisplayName="Event Thumbnail" RichText="TRUE" RichTextMode="ThemeHtml" Description="This image will show only in the events listing page (landing page)" Required="TRUE" Group="Research Event Columns" ID="{825d2283-78f4-4878-b4c5-318cdc15f949}" SourceID="{ab60d3a0-898d-46c5-a8c3-797a3c2f6b11}" StaticName="EventThumbnail" Name="EventThumbnail" Version="1" Hidden="FALSE" Customization="" ReadOnly="FALSE" PITarget="" PrimaryPITarget="" PIAttribute="" PrimaryPIAttribute="" Aggregation="" Node="" />
    <Field Type="DateTime" DisplayName="Event Start Date" Required="TRUE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateTime" Group="Research Event Columns" ID="{71800b8f-3d7c-4356-bb1a-dee72d1b3c78}" SourceID="{ab60d3a0-898d-46c5-a8c3-797a3c2f6b11}" StaticName="EventStartDate" Name="EventStartDate" Hidden="FALSE" Customization="" ReadOnly="FALSE" PITarget="" PrimaryPITarget="" PIAttribute="" PrimaryPIAttribute="" Aggregation="" Node="" />
    <Field Type="DateTime" DisplayName="Event End Date" Required="TRUE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateTime" Group="Research Event Columns" ID="{5ff912dd-19c8-43c1-ba50-5a4734740ab7}" SourceID="{ab60d3a0-898d-46c5-a8c3-797a3c2f6b11}" StaticName="EventEndDate" Name="EventEndDate" Hidden="FALSE" Customization="" ReadOnly="FALSE" PITarget="" PrimaryPITarget="" PIAttribute="" PrimaryPIAttribute="" Aggregation="" Node="" />

    <ContentType ID="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D01" Name="Research Events" Group="Research Content Types" Version="11">
        <FieldRefs>
            <FieldRef ID="{63da83d2-2e0a-4556-8136-8b6a4acdb1bc}" />
            <FieldRef ID="{4f4fe0d4-a72c-4afe-8585-d7a76c4f15b5}" />
            <FieldRef ID="{bfe967b8-0ba1-4757-8c5d-d6652719865c}" />
            <FieldRef ID="{825d2283-78f4-4878-b4c5-318cdc15f949}" />
            <FieldRef ID="{71800b8f-3d7c-4356-bb1a-dee72d1b3c78}" />
            <FieldRef ID="{5ff912dd-19c8-43c1-ba50-5a4734740ab7}" />
        </FieldRefs>
    </ContentType>
    <!--############################# End Research Events Site Columns & Content Type ###############################-->
</Elements>

and my provisioning class looks like this:

public override void Provision(SPWebProvisioningProperties props)
        {
            // apply template using a configuration for Blank Publishing site
            props.Web.ApplyWebTemplate("BLANKINTERNET#0");

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite siteCollection = new SPSite(props.Web.Site.ID))
                {
                    using (SPWeb site = siteCollection.OpenWeb(props.Web.ID))
                    {

                        siteCollection.Features.Add(new Guid("a6bce603-1626-41ff-a107-3561f379be6d"));

                        site.Title = "Research Center Site Title";
                        site.Description = "This site was created on " + DateTime.Now.ToShortDateString();
                        site.Update();
                    }
                }
            });
        }

is there any known issue regarding creating content types using the provisioning providers?

1 Answer 1

2

You need to have a "Name" property, "DisplayName", etc on the fieldref in addition to just the GUID. Here is a link to the FieldRef element. Check the required fields.

http://msdn.microsoft.com/en-us/library/aa543225.aspx

2
  • It Worked. after adding the name and the display name attributes. Strange though because VS 2010 is not enforcing these attributes for the fieldRef element Commented Jun 13, 2011 at 7:12
  • Visual Studio's intellisense can be spotty both in terms of missing required elements, and identifying invalid elements. You can't really trust it. Commented Jun 13, 2011 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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