Question

I'm trying to add some provisioning function to my SPfx WebPart Project on SharePoint Online. The Problem is that as soon as I put the feature information to my package-solution.json the configured lists deploy properly but I can't add the WebPart itself on a Sitepage.

I'm working with Visual Studio Code on a SPfx WebPart Project for SharePoint Online. I already deployed a variety of WebParts an Extensions within our Companys' tenant but I'm pretty new to the thing with features and assets.

My WebPart needs two specific lists which it should deploy by itself when added to the site contents per [New] -> [App]. Therefore I added an elements.xml and two schema-*.xml files to my project and modified the package-solution.json to include them as a feature.

Since then the Lists a deployed properly to the SiteCollection or SubSite where I add the App. BUT(!) the WebPart itself doesn't show up when editing a SitePage and adding WebParts. Its not even in the popup where you select the WebPart you want.

There are no Install Errors when adding the App too the SiteCollection and the WebPart works well when the feature information is deleted from the package-solution.json.

And here I am, having no clue what's wrong and needing your help.

package-solution.json

{
  "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
  "solution": {
    "name": "sp-bookingtool-admin",
    "id": "30d57d62-8319-4b29-b0f9-***********",
    "version": "2.0.0.6",
    "features": [
      {
        "title": "sp-bookingtool-admin-features",
        "description": "asset-deployment-webpart-client-side-solution",
        "id": "523fe887-ced5-4036-b564-***********",
        "version": "2.0.0.6",
        "assets": {
          "elementManifests": [
            "elements.xml"
          ],
          "elementFiles": [
            "schema-sessions.xml",
            "schema-courses.xml"
          ]
        }
      }
    ]
  },
  "paths": {
    "zippedPackage": "solution/sp-bookingtool-admin.sppkg"
  }
}

elements.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

    <ListInstance
            CustomSchema="schema-sessions.xml"
            FeatureId="00bfea71-de22-43b2-a848-***********"
            Title="BookingTool-Sessions"
            Description="BookingTool-Sessions"
            TemplateType="100"
            Url="Lists/BookingToolSessions">
    </ListInstance>

    <ListInstance
            CustomSchema="schema-courses.xml"
            FeatureId="00bfea71-de22-43b2-a848-***********"
            Title="BookingTool-Courses"
            Description="BookingTool-Courses"
            TemplateType="100"
            Url="Lists/BookingToolCourses">
    </ListInstance>

</Elements>

1 of two schema.xml

<List xmlns:ows="Microsoft SharePoint" Title="BookingTool-Courses" EnableContentTypes="TRUE" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/BookingToolCourses" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
  <MetaData>
    <Fields>
      <Field ID="{1e513910-8092-45f7-b996-***********}" Name="Text_1" Type="Text" DisplayName="Text_1"  Group="" Required="TRUE"/>
      <Field ID="{d82721d4-0b3c-48cf-9a24-***********}" Name="Text_2" Type="Text" DisplayName="Text_2" Group="" Required="TRUE"/>
    </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">
        <RowLimit Paged="TRUE">30</RowLimit>
        <Toolbar Type="Standard" />
        <ViewFields>
          <FieldRef Name="LinkTitle"></FieldRef>
        </ViewFields>
        <Query>
          <OrderBy>
            <FieldRef Name="LinkTitle" />
          </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>
Was it helpful?

Solution

Thanks to a collegue I found the error by myself.

Against my expectation the "FeatureID" in the ListInstances is NOT a GUID of the developed feature BUT the ID of the Listtemplate you use depending of the "TemplateType".

<ListInstance
     CustomSchema="schema-sessions.xml"
     FeatureId="00bfea71-de22-43b2-a848-c05709900100"
     Title="BookingTool-Sessions"
     Description="BookingTool-Sessions"
     TemplateType="100"
     Url="Lists/BookingToolSessions">
</ListInstance>

00bfea71-de22-43b2-a848-c05709900100 is the ID for Custom Lists and 100 is the Templatetype for that List.

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