4

In my solution Everything working fine except below two things.I have refer this link to create list

  1. I am not able to remove title column from List
  2. When I go to List Setting I can't see content type which I used to create a List

enter image description here

Note:- But When I tried to add this content type to list It looks like that it's already added. When I click on Item Content type it shows that it inherited from Cost Center content Type. enter image description here

I have used below code

package-solution.json

{
    "solution": {
        "name": "practice",
        "id": "cd473f16-232e-418e-ba70-6c02ed46c704",
        "version": "1.0.1.9",
        "features": [{
          "title": "practice",
          "description": "practice solution to Create List and Site Content type on web",
          "id": "d46cd9d6-87fc-473b-a4c0-db9ad9162b64",
          "version": "1.0.0.0",
          "assets": {        
            "elementManifests": [
              "elements.xml"
            ],
            "elementFiles":[
              "schema.xml"
            ]
          }
        }]
      },
      "paths": {
        "zippedPackage": "solution/acco-practice.sppkg"
      }
    }

elements.xml

    <Field ID="{060E50AC-E9C1-4D3C-B1F9-DE0BCAC300F6}"
            Name="SPFxAmount"
            DisplayName="Amount"
            Type="Currency"
            Decimals="2"
            Min="0"
            Required="True"
            Group="SPFx Columns" />

    <Field ID="{943E7530-5E2B-4C02-8259-CCD93A9ECB18}"
            Name="SPFxCostCenter"
            DisplayName="Cost Center"
            Type="Choice"
            Required="FALSE"
            Group="SPFx Columns">
        <CHOICES>
        <CHOICE>Administration</CHOICE>
        <CHOICE>Information</CHOICE>
        <CHOICE>Facilities</CHOICE>
        <CHOICE>Operations</CHOICE>
        <CHOICE>Sales</CHOICE>
        <CHOICE>Marketing</CHOICE>
        </CHOICES>
    </Field>

    <ContentType ID="0x010042D0C1C200A14B6887742B6344675C8B" 
            Name="Cost Center" 
            Group="SPFx Content Types" 
            Inherits="FALSE"
            Description="Sample content types from web part solution">
        <FieldRefs>
            <RemoveFieldRef  ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="LinkTitle" />
            <FieldRef ID="{060E50AC-E9C1-4D3C-B1F9-DE0BCAC300F6}" /> 
            <FieldRef ID="{943E7530-5E2B-4C02-8259-CCD93A9ECB18}" />
        </FieldRefs>
    </ContentType> 

    <ListInstance 
            CustomSchema="schema.xml"
            FeatureId="00bfea71-de22-43b2-a848-c05709900100"
            Title="SPFx List" 
            Description="SPFx List"
            TemplateType="100"
            Url="Lists/SPFxList" >
    </ListInstance>
</Elements>

Schema.xml

<List xmlns:ows="Microsoft SharePoint" Title="SPFxList" EnableContentTypes="TRUE" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/SPFxList" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
  <MetaData>
    <ContentTypes>
      <ContentTypeRef Name="Cost Center"  ID="0x010042D0C1C200A14B6887742B6344675C8B" />
    </ContentTypes>
    <Fields></Fields>
    <Views>
      <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">
        <XslLink Default="TRUE">main.xsl</XslLink>
        <JSLink>clienttemplates.js</JSLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <Toolbar Type="Standard" />
        <ViewFields>
          <FieldRef Name="SPFxAmount"></FieldRef>
          <FieldRef Name="SPFxCostCenter"></FieldRef>
        </ViewFields>
        <Query>
          <OrderBy>
            <FieldRef Name="ID" />
          </OrderBy>
        </Query>
      </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>

Any help will Appreciate.

  • 1
    Is 'Allow management of content types' set under Advanced settings? – Michael Colbs Sep 21 '17 at 16:31
  • Allow management of content types? Check Yes – Bharat Khunti Sep 22 '17 at 6:19
  • Thanks. As you can see Schema.xml file I have set "EnableContentTypes="TRUE" – Bharat Khunti Sep 22 '17 at 6:25
1

I was able to reproduce this issue and was able to fix it as below:

You needn't specify LinkTitle name, its not needed.

In schema.xml, I changed the ContentTypeRef to ContentType and added the fields

Modify the content type tag in elements.xml as below:

<ContentType ID="0x010042D0C1C200A14B6887742B6344675C8B" 
            Name="Cost Center" 
            Group="SPFx Content Types" 
            Inherits="FALSE"
            Description="Sample content types from web part solution">
        <FieldRefs>
            <RemoveFieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" />
            <FieldRef ID="{060E50AC-E9C1-4D3C-B1F9-DE0BCAC300F6}" /> 
            <FieldRef ID="{943E7530-5E2B-4C02-8259-CCD93A9ECB18}" />
        </FieldRefs>
    </ContentType> 

Modify the schema.xml as below:

<List xmlns:ows="Microsoft SharePoint" Title="SPFxList" EnableContentTypes="TRUE" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/SPFxList" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
  <MetaData>
    <ContentTypes>
      <ContentType Name="Cost Center" ID="0x010042D0C1C200A14B6887742B6344675C8B" Group="SPFx Content Types" Inherits="FALSE">
        <FieldRefs>          
          <FieldRef ID="{060E50AC-E9C1-4D3C-B1F9-DE0BCAC300F6}" /> 
          <FieldRef ID="{943E7530-5E2B-4C02-8259-CCD93A9ECB18}" />          
        </FieldRefs>
      </ContentType>
    </ContentTypes>
    <Fields></Fields>
    <Views>..rest of your code

After that, bundle,package, upload and deploy the solution.

It will show up the correct content type in your list. The Title field will be "hidden" from the new/edit forms as well as your content type.

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.