Tuesday, August 30, 2011

Creating List & Contenty Type with Visual Studio


//Product->Elements.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- Parent ContentType: Item (0x01) -->

  <Field SourceID="http://schemas.microsoft.com/sharepoint/v3"
        ID="{36819A9B-E748-47D5-9949-A65DD195BF80}"
        Name="ProductDescription"
        DisplayName="Product Description"
        Group="My Custom Columns"
        Type="Text"
        DisplaceOnUpgrade="TRUE" />

  <Field SourceID="http://schemas.microsoft.com/sharepoint/v3"
         ID="{5CD2C0C1-67AC-4F9E-BF21-463CFEE9B382}"
         Name="ProductID"
         DisplayName="Product ID"
         Group="My Custom Columns"
         Type="Number"
         DisplaceOnUpgrade="TRUE" />

  <ContentType ID="0x0100fb1ad12faa9b4834ad4d590f0f030151"
              Name="Product"
              Group="My Custom Content Types"
              Version="0">
    <FieldRefs>
      <FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"
                Name="Title"
                DisplayName="Product Name" />
      <FieldRef ID="{36819A9B-E748-47D5-9949-A65DD195BF80}"
                Name="ProductDescription" />
      <FieldRef ID="{5CD2C0C1-67AC-4F9E-BF21-463CFEE9B382}"
                Name="ProductID" />
    </FieldRefs>
  </ContentType> 
 
  <ContentType ID="0x0100e4b24eca7bb9486b8a40e6143a7d884e"
               Name="ListsAndSchemas - Product"
               Group="Custom Content Types"
               Description="My Content Type"
               Inherits="TRUE"
               Version="0">
    <FieldRefs>
    </FieldRefs>
  </ContentType>
</Elements>
----------------------------------------------------------------------------------------
//ProductList->Elements.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <!-- Do not change the value of the Name attribute below. If it does not match the folder name of the List Definition project item, an error will occur when the project is run. -->
    <ListTemplate
        Name="ProductList"
        Type="100001"
        BaseType="0"
        OnQuickLaunch="TRUE"
        SecurityBits="11"
        Sequence="410"
        DisplayName="ListsAndSchemas - ProductList"
        Description="My List Definition"
        Image="/_layouts/images/itgen.png"/>
</Elements>
-----------------------------------------------------------------------------------------------

//ProductList->Schema.xml
<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="ListsAndSchemas - ProductList" EnableContentTypes="TRUE" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/ListsAndSchemas-ProductList" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
  <MetaData>
    <ContentTypes>
      <ContentTypeRef ID="0x01">
        <Folder TargetName="Item" />
      </ContentTypeRef>
      <ContentTypeRef ID="0x0120" />
      <ContentTypeRef ID="0x0100fb1ad12faa9b4834ad4d590f0f030151" />
    </ContentTypes>
    <Fields>
      <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"
            Name="Title"
            DisplayName="Product Name"
            Type="Text" />
      <Field ID="{36819A9B-E748-47D5-9949-A65DD195BF80}"
             Name="ProductDescription"
             DisplayName="Product Description"
             Type="Text" />
      <Field ID="{5CD2C0C1-67AC-4F9E-BF21-463CFEE9B382}"
             Name="ProductID"
             DisplayName="ProductID"
             Type="Number" />
    </Fields>
    <Views>
      <View BaseViewID="0" Type="HTML" MobileView="TRUE" TabularView="FALSE">
        <Toolbar Type="Standard" />
        <XslLink Default="TRUE">main.xsl</XslLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <ViewFields>
          <FieldRef Name="LinkTitleNoMenu"></FieldRef>
          <FieldRef ID="{36819A9B-E748-47D5-9949-A65DD195BF80}"
         Name="ProductDescription"
         DisplayName="Product Description" />
          <FieldRef ID="{5CD2C0C1-67AC-4F9E-BF21-463CFEE9B382}"
                 Name="ProductID"
                 DisplayName="ProductID" />
        </ViewFields>
        <Query>
          <OrderBy>
            <FieldRef Name="Modified" Ascending="FALSE"></FieldRef>
          </OrderBy>
        </Query>
        <ParameterBindings>
          <ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)" />
          <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
          <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_ONET_HOME)" />
        </ParameterBindings>
      </View>
      <View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/images/generic.png" Url="AllItems.aspx">
        <Toolbar Type="Standard" />
        <XslLink Default="TRUE">main.xsl</XslLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <ViewFields>
          <FieldRef Name="Attachments"></FieldRef>
          <FieldRef Name="LinkTitle"></FieldRef>
          <FieldRef ID="{36819A9B-E748-47D5-9949-A65DD195BF80}"
          Name="ProductDescription"
          DisplayName="Product Description" />
          <FieldRef ID="{5CD2C0C1-67AC-4F9E-BF21-463CFEE9B382}"
                 Name="ProductID"
                 DisplayName="ProductID" />
        </ViewFields>
        <Query>
          <OrderBy>
            <FieldRef Name="ID"></FieldRef>
          </OrderBy>
        </Query>
        <ParameterBindings>
          <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
          <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
        </ParameterBindings>
      </View>
    </Views>
    <Forms>
      <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
      <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
      <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
    </Forms>
  </MetaData>
</List>
------------------------------------------------------------------------------------------------

//ProductList->Products->Elements.xml
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListInstance Title="Products"
               OnQuickLaunch="TRUE"
               TemplateType="10001"
               Url="Lists/Products"
               Description="">
  </ListInstance>
</Elements>
---------------------------------------------------------------------------------------------

No comments:

Post a Comment

Featured Post

Azure OpenAI Chat and DALL-E in C# and Python

Azure OpenAI Chat in C#: // Install the .NET library via NuGet: dotnet add package Azure.AI.OpenAI --version 1.0.0-beta.5   using System; u...

Popular posts