Home > 2013 > Creating Content Type using Schema.xml

Creating Content Type using Schema.xml

May 24Hits:2
Advertisement

I am trying to create a content type from a schema.xml but the fields are not getting created, any ideas?

<ContentType ID="0x0101001CC4D99118BEC246AB8D5DF12A34B61F0101" Name="License" Group="Smile" Version="3">     <Folder TargetName="_cts/License" />     <Fields>       <Field ID="{c042a256-787d-4a6f-8a8a-cf6ab767f12d}" Name="ContentType" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="ContentType" Group="_Hidden" Type="Computed" DisplayName="Content Type" Sealed="TRUE" Sortable="FALSE" RenderXMLUsingPattern="TRUE" PITarget="MicrosoftWindowsSharePointServices" PIAttribute="ContentTypeID" Customization="">         <FieldRefs>           <FieldRef ID="{03e45e84-1992-4d42-9116-26f756012634}" Name="ContentTypeId" />         </FieldRefs>         <DisplayPattern>           <MapToContentType>             <Column Name="ContentTypeId" />           </MapToContentType>         </DisplayPattern>       </Field>       <Field ID="{5f47e085-2150-41dc-b661-442f3027f552}" Name="SelectFilename" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="SelectFilename" Group="_Hidden" ReadOnly="TRUE" Type="Computed" DisplayName="Select" Hidden="TRUE" CanToggleHidden="TRUE" Filterable="FALSE" AuthoringInfo="(web part connection)" HeaderImage="blank.gif" Sortable="FALSE" Customization="">         <FieldRefs>           <FieldRef ID="{1d22ea11-1e32-424e-89ab-9fedbadb6ce1}" Name="ID" />         </FieldRefs>         <DisplayPattern>           <IfEqual>             <Expr1>               <GetVar Name="SelectedID" />             </Expr1>             <Expr2>               <Column Name="ID" />             </Expr2>             <Then>               <HTML><![CDATA[<img align="absmiddle" style="cursor: hand" src="/_layouts/15/images/rbsel.gif?rev=23" alt="]]></HTML>               <HTML>Selected</HTML>               <HTML><![CDATA[">]]></HTML>             </Then>             <Else>               <HTML><![CDATA[<a href="javascript:SelectField(']]></HTML>               <GetVar Name="View" />               <HTML><![CDATA[',']]></HTML>               <ScriptQuote NotAddingQuote="TRUE">                 <Column Name="ID" />               </ScriptQuote>               <HTML><![CDATA[');return false;" onclick="javascript:SelectField(']]></HTML>               <GetVar Name="View" />               <HTML><![CDATA[',']]></HTML>               <ScriptQuote NotAddingQuote="TRUE">                 <Column Name="ID" />               </ScriptQuote>               <HTML><![CDATA[');return false;" target="_self">]]></HTML>               <HTML><![CDATA[<img border="0" align="absmiddle" style="cursor: hand" src="/_layouts/15/images/rbunsel.gif?rev=23"  alt="]]></HTML>               <HTML>Normal</HTML>               <HTML><![CDATA[">]]></HTML>               <HTML><![CDATA[</a>]]></HTML>             </Else>           </IfEqual>         </DisplayPattern>       </Field>       <Field ID="{8553196d-ec8d-4564-9861-3dbe931050c8}" Name="FileLeafRef" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="FileLeafRef" Group="_Hidden" ShowInFileDlg="FALSE" ShowInVersionHistory="FALSE" Type="File" DisplayName="Name" AuthoringInfo="(for use in forms)" List="Docs" FieldRef="ID" ShowField="LeafName" JoinColName="DoclibRowId" JoinRowOrdinal="0" JoinType="INNER" Required="TRUE" Customization="" />       <Field ID="{8c06beca-0777-48f7-91c7-6da68bc07b69}" Name="Created" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Created" Group="_Hidden" ColName="tp_Created" RowOrdinal="0" ReadOnly="TRUE" Type="DateTime" DisplayName="Created" StorageTZ="TRUE" Hidden="TRUE" Customization="" />       <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title" Group="_Hidden" Type="Text" DisplayName="Title" Required="FALSE" FromBaseType="TRUE" Customization="" ShowInNewForm="FALSE" ShowInEditForm="TRUE" />       <Field ID="{28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f}" Name="Modified" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Modified" Group="_Hidden" ColName="tp_Modified" RowOrdinal="0" ReadOnly="TRUE" Type="DateTime" DisplayName="Modified" StorageTZ="TRUE" Hidden="TRUE" Customization="" />       <Field ID="{822c78e3-1ea9-4943-b449-57863ad33ca9}" Name="Modified_x0020_By" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Modified_x0020_By" Group="_Hidden" ReadOnly="TRUE" Hidden="FALSE" Type="Text" DisplayName="Document Modified By" Customization="" />       <Field ID="{4dd7e525-8d6b-4cb4-9d3e-44ee25f973eb}" Name="Created_x0020_By" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Created_x0020_By" Group="_Hidden" ReadOnly="TRUE" Hidden="FALSE" Type="Text" DisplayName="Document Created By" Customization="" />       <Field Type="DateTime" DisplayName="Expires" Description="Enter the date this record will expire." Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateOnly" Group="*Operation Smile" FriendlyDisplayFormat="Disabled" ID="{45a8379e-5d0c-458a-be50-6c2cbf460cb0}" SourceID="{a0c66250-262a-48da-8fe8-ab76ae5e67ea}" StaticName="Expires1" Name="Expires1" Customization="" />       <Field Type="DateTime" DisplayName="ExpirationAlertDate" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" Format="DateOnly" Group="*Operation Smile" FriendlyDisplayFormat="Disabled" ID="{c01f9abd-1571-4f5f-9b4a-34e37f6e6a1b}" SourceID="{a0c66250-262a-48da-8fe8-ab76ae5e67ea}" StaticName="ExpirationAlertDate" Name="ExpirationAlertDate" Customization="" />       <Field ID="{B0227F1A-B179-4D45-855B-A18F03706BCB}" Name="_dlc_Exempt" StaticName="_dlc_Exempt" DisplayName="Exempt from Policy" SourceID="http://schemas.microsoft.com/sharepoint/v3" Group="Document and Record Management Columns" Type="ExemptField" Indexed="FALSE" Hidden="TRUE" CanToggleHidden="TRUE" ShowInNewForm="FALSE" ShowInEditForm="FALSE" ShowInFileDlg="FALSE" ShowInDisplayForm="FALSE" Required="FALSE" Sealed="TRUE" ReadOnly="TRUE" OverwriteInChildScopes="TRUE" Customization="" />       <Field ID="{74E6AE8A-0E3E-4DCB-BBFF-B5A016D74D64}" Name="_dlc_ExpireDateSaved" StaticName="_dlc_ExpireDateSaved" DisplayName="Original Expiration Date" SourceID="http://schemas.microsoft.com/sharepoint/v3" Group="Document and Record Management Columns" Type="DateTime" Indexed="FALSE" Hidden="TRUE" CanToggleHidden="TRUE" ShowInNewForm="FALSE" ShowInEditForm="FALSE" ShowInFileDlg="FALSE" ShowInDisplayForm="FALSE" Required="FALSE" Sealed="TRUE" ReadOnly="TRUE" OverwriteInChildScopes="TRUE" Customization="" />       <Field ID="{ACD16FDF-052F-40F7-BB7E-564C269C9FBC}" Name="_dlc_ExpireDate" StaticName="_dlc_ExpireDate" DisplayName="Expiration Date" SourceID="http://schemas.microsoft.com/sharepoint/v3" Group="Document and Record Management Columns" Type="DateTime" Indexed="FALSE" Hidden="FALSE" CanToggleHidden="TRUE" ShowInNewForm="FALSE" ShowInEditForm="FALSE" ShowInFileDlg="FALSE" ShowInDisplayForm="FALSE" Required="FALSE" Sealed="TRUE" ReadOnly="TRUE" OverwriteInChildScopes="TRUE" Customization="">       </Field>     </Fields>     <XmlDocuments>       <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events">         <spe:Receivers xmlns:spe="http://schemas.microsoft.com/sharepoint/events">           <Receiver>             <Name>Microsoft.Office.RecordsManagement.PolicyFeatures.ExpirationEventReceiver</Name>             <Synchronization>Synchronous</Synchronization>             <Type>10001</Type>             <SequenceNumber>101</SequenceNumber>             <Url>             </Url>             <Assembly>Microsoft.Office.Policy, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>             <Class>Microsoft.Office.RecordsManagement.Internal.UpdateExpireDate</Class>             <Data>             </Data>             <Filter>             </Filter>           </Receiver>           <Receiver>             <Name>Microsoft.Office.RecordsManagement.PolicyFeatures.ExpirationEventReceiver</Name>             <Synchronization>Synchronous</Synchronization>             <Type>10002</Type>             <SequenceNumber>102</SequenceNumber>             <Url>             </Url>             <Assembly>Microsoft.Office.Policy, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>             <Class>Microsoft.Office.RecordsManagement.Internal.UpdateExpireDate</Class>             <Data>             </Data>             <Filter>             </Filter>           </Receiver>           <Receiver>             <Name>Microsoft.Office.RecordsManagement.PolicyFeatures.ExpirationEventReceiver</Name>             <Synchronization>Synchronous</Synchronization>             <Type>10004</Type>             <SequenceNumber>103</SequenceNumber>             <Url>             </Url>             <Assembly>Microsoft.Office.Policy, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>             <Class>Microsoft.Office.RecordsManagement.Internal.UpdateExpireDate</Class>             <Data>             </Data>             <Filter>             </Filter>           </Receiver>           <Receiver>             <Name>Microsoft.Office.RecordsManagement.PolicyFeatures.ExpirationEventReceiver</Name>             <Synchronization>Synchronous</Synchronization>             <Type>10006</Type>             <SequenceNumber>104</SequenceNumber>             <Url>             </Url>             <Assembly>Microsoft.Office.Policy, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>             <Class>Microsoft.Office.RecordsManagement.Internal.UpdateExpireDate</Class>             <Data>             </Data>             <Filter>             </Filter>           </Receiver>           <Receiver>             <Name>Microsoft.Office.RecordsManagement.PolicyFeatures.ExpirationEventReceiver</Name>             <Synchronization>Synchronous</Synchronization>             <Type>10009</Type>             <SequenceNumber>105</SequenceNumber>             <Url>             </Url>             <Assembly>Microsoft.Office.Policy, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>             <Class>Microsoft.Office.RecordsManagement.Internal.UpdateExpireDate</Class>             <Data>             </Data>             <Filter>             </Filter>           </Receiver>         </spe:Receivers>       </XmlDocument>       <XmlDocument NamespaceURI="office.server.policy">         <p:Policy xmlns:p="office.server.policy" id="" local="true">           <p:Name>Expiring Documents</p:Name>           <p:Description>           </p:Description>           <p:Statement>           </p:Statement>           <p:PolicyItems>             <p:PolicyItem featureId="Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration" staticId="0x0101001CC4D99118BEC246AB8D5DF12A34B61F01|726354630" UniqueId="c324a1a6-bb2d-4e52-b86a-c2b8b79f83cb">               <p:Name>Retention</p:Name>               <p:Description>Automatic scheduling of content for processing, and performing a retention action on content that has reached its due date.</p:Description>               <p:CustomData>                 <Schedules nextStageId="2">                   <Schedule type="Default">                     <stages>                       <data stageId="1">                         <formula id="Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration.Formula.BuiltIn">                           <number>0</number>                           <property>ExpirationAlertDate</property>                           <propertyId>c01f9abd-1571-4f5f-9b4a-34e37f6e6a1b</propertyId>                           <period>days</period>                         </formula>                         <action type="workflow" id="fb97da3d-4c25-4c1a-8e7d-d9d87a17741b" />                       </data>                     </stages>                   </Schedule>                 </Schedules>               </p:CustomData>             </p:PolicyItem>           </p:PolicyItems>         </p:Policy>       </XmlDocument>       <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">         <FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms">           <Display>DocumentLibraryForm</Display>           <Edit>DocumentLibraryForm</Edit>           <New>DocumentLibraryForm</New>         </FormTemplates>       </XmlDocument>     </XmlDocuments>   </ContentType> 

Answers

As per your code blocks, before <ContentType>, You need to create your custom fields. I guess you are missing that, that is why you are unable to see that fields. Your Schema.xml should like as below:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Field ID="{00D74D75-B775-4222-967D-D26973B8C5DB}" Name="CustomField" DisplayName="Custom Field" Type="Text"/>
  <Field ID="{C3CD561C-D714-42DE-8112-C830B4108CEF}" Name="CustomChoiceField" DisplayName="Custom Choice Field" Type="Choice">
    <CHOICES>
      <CHOICE>Choice 1</CHOICE>
      <CHOICE>Choice 2</CHOICE>
      <CHOICE>Choice 3</CHOICE>
    </CHOICES>
  </Field>
  <!-- Your Content type code blocks here -->
  <ContentType ID="0x0101001CC4D99118BEC246AB8D5DF12A34B61F0101" Name="License" Group="Smile" Version="3">
      .....Your Content type code blocks here....
  </ContentType>
</Elements>

Read this - Create Content Type Using Schema article for more.

Related Articles

  • Creating Content Type using Schema.xmlMay 24

    I am trying to create a content type from a schema.xml but the fields are not getting created, any ideas? <ContentType ID="0x0101001CC4D99118BEC246AB8D5DF12A34B61F0101" Name="License" Group="Smile" Version="3">

  • Create content type from xml using client server object modelJune 23

    I have one xml in which all the declaration of the content type are added like <ContentTypes> <!-- All Content Type Declarations --> </ContentTypes> I can't use sandbox solution for that, so I want to achieve only using client object mod

  • Programatically create content type for multilingual siteNovember 13

    How to create content type for for multilingual site programatically. Example Content type column internal name: firstName. English Display Name: First Name, German Display Name:Vorname. Same for all column name and content type name. How can I do th

  • create content type from workflow taskAugust 28

    I have been looking all over the internet for instructions on how to create a content type based off the Workflow Task type. Everything I have found thus far seems like it is incomplete or has gaps that I can't seem to bridge. I am using Visual Studi

  • Create Content type with metadata fieldDecember 18

    I made the following Powershell script to create a content type with a text field and a numeric field: $url = "http://my-sharepoint-site" $web = get-spweb $url $ctypeName = "Content type X" $ctypeParent = $web.availablecontenttypes[&qu

  • Does Create Content Type need to be a farm solution?April 27

    I've found a couple of examples of creating a content type using visual studio. http://stevemannspath.blogspot.com/2010/11/sharepoint-2010-leveraging-visual.html http://msdn.microsoft.com/en-us/library/ff630942.aspx They both say "Deploy as Farm Solu

  • How to create content type programaticallySeptember 11

    how to create content type programatically and attach field api fields to it? hook_node_info() will not work for me since i want to create my node type and its instance in a single method (for testing purposes), so kindly suggest a solution other tha

  • creating content types with Out-of-Box vs Server Object modelsFebruary 23

    Are there any advantages in creating content type using out of box vs visual studios? --------------Solutions------------- I'm assuming that by "out of the box" you mean creating them in the User Interface. Advantages of Visual Studio Easy way t

  • How to create content type Drupal 7 October 12

    I need to add a new content type to the node/add page. How can I go about doing this? --------------Solutions------------- You should try Google before posting questions like this here. One of the first few results is the following video: Drupal 7: C

  • How to create Content Types with DrushJune 9

    Is it possible to create content types with Drush? Such as a new Galery content type? I created a content type manually via web interface and checked the changes in database. However, there are quite a lot of changes - some changes are also in blob f

  • How to create content type programmatically with fields and vertical tabsFebruary 3

    I'm creating a module using Drupal7.26 and want to create content type with different type of fields like radio/checkboxes/drupdown and textfields. I'm following the last comment by Jason Gray in THIS thread and is working pretty well except it is no

  • Programmatically created content type don't have a delete link

    Programmatically created content type don't have a delete linkFebruary 12

    I'm developing a module that creates new content types through form that I created (not in hook_install): function create_new_content_type($type, $name){ $t = get_t(); $new_node = array( 'type' => $type, 'name' => $name, 'base' => 'node_content',

  • create Content Types like Excel,PowerPoint,One Note documents for document library in SP2013?October 14

    I want to create Content Types like Excel,PowerPoint,One Note documents for document library in SP2013,by default once enable the content type in Advance settings,we can able to see the Word content type,In site settings->site content types i can abl

  • Programmatically created content type module title not workingApril 8

    I created a module with a .info, .module and .install file that can be installed by customers. This module file to create content types from node consists basically atm of: /** * Implements hook_node_info() */ function mycontent_node_info() { return

  • Crash on creating content type?May 26

    I'm working on a D7.27 site I've inherited and when adding a new content type I'm getting this error: DatabaseSchemaObjectExistsException: Table <em class="placeholder">field_data_body</em> already exists. in DatabaseSchema->creat

  • Declaratively created content type is losing event receivers on listOctober 5

    I declaratively created a content type which has an attached event receiver. I attached this ct to a list which is also being done via xml declaration. In principle all components are working. The event receiver is working, the list is being correctl

  • List Content types not getting updating while adding a site column to already deployed site content type using elements.xmlDecember 14

    I have a site content type deployed through element.xml and is used inside lists. I added one site column and referenced that in content type. So my element.xml looks like below <?xml version="1.0" encoding="utf-8"?> <Elements

  • Create Content Type with a Default TitleMay 12

    How would for the Title of something to be default, static, unchanageable? I've got a content type (plus others planned) that I plan on using as a data submittal for stuff similar to a "Quote of the Day" or "Create an Event for the Calendar

  • How can I set frequency of each content type with the XML sitemap module?June 29

    I use the XML sitemap module (7.x-2.0-beta3) to generate the XML sitemap for my site. The problem is that I cannot set the change frequency of the content types. In "admin/config/search/xmlsitemap/settings" I have a "Change frequency"

  • Creating content types with fields that are other content types?November 17

    I have an existing content type in my current Drupal application, person. This contains all of the data you would expect, more or less - name, address, employer, etc. I'd like to create a project content type. A project will consist of a name, descri

Copyright (C) 2017 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 1.058 s.