5

I am trying to create custom list using SharePoint Framework. I created a folder with name Assets under SharePoint folder and created a element.xml in the Assets and updated the package-solution.json accordingly. But the list is not created . The app is installing in the site(Developer Site) without any errors. Am i missing anything.

My element.xml and package-solution.json are as below:

element.xml

<?xml version="1.0" encoding="utf-8"?>  
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">  
    <ListInstance FeatureId="00bfea71-de22-43b2-a848-c05709900100"
     Title="CustomList2" 
     Description="Custom List2 Created Using SharePoint Framework" 
     TemplateType="100" 
     Url="Lists/CustomList2"> </ListInstance>  
</Elements>  

package-solution.json

{
  "solution": {
    "name": "multiplelists-client-side-solution",
    "id": "41fc6d0f-14d6-4166-b1a1-9211daa8395f",
    "version": "1.0.0.0",
      "Assets": {        
    "elementManifests": [
      "elements.xml"
    ],
    "elementFiles":[
      "schema.xml"]
  }

  },
  "paths": {
    "zippedPackage": "solution/multiplelists.sppkg"
  }
}

Schema.xml :

<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint" Title="CustomList2" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/CustomList2" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/">
  <MetaData>
    <ContentTypes>
      <ContentTypeRef ID="0x01">

      </ContentTypeRef>
      <ContentTypeRef ID="0x0120" />
    </ContentTypes>
    <Fields>
      <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Type="Text" Name="Title" DisplayName="$Resources:core,Title;" Required="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title" MaxLength="255" />
    </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/15/images/generic.png?rev=23" Url="AllItems.aspx">
        <Toolbar Type="Standard" />
        <XslLink Default="TRUE">main.xsl</XslLink>
        <JSLink>clienttemplates.js</JSLink>
        <RowLimit Paged="TRUE">30</RowLimit>
        <ViewFields>
          <FieldRef Name="LinkTitle"></FieldRef>
        </ViewFields>

      </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>

Folder structure:

Folder structure:

Reference Link : SPFX Provision list with data :

  • Have you created Schema.xml same as the person in your reference link has done? – SynozeN Technologies May 16 '17 at 7:43
  • No. I am trying to simple custom list. not with data.. – TARUN May 16 '17 at 7:45
  • That is ok but have you defined your columns which you want there? – SynozeN Technologies May 16 '17 at 7:46
  • I just want to create a simple custom list without data and Columns – TARUN May 16 '17 at 8:04
1

You can follow the steps mentioned here Adding custom list to SharePoint framework app - SPFx app.

2

As an alternative, since your code runs Client Side you can also use REST to create a List

https://social.technet.microsoft.com/wiki/contents/articles/37608.sharepoint-online-create-and-delete-list-using-rest-api.aspx

  • Hi Danny,Thanks for the link. i just want to create the lists in the site while adding app to the site using SPFX. Reference Link everythingsharepoint.blogspot.in/2017/04/… – TARUN May 16 '17 at 9:10
  • 1
    Problem with the traditional (dumb) "Back-end" push method is that it does not take into account all scenarios that can exist on the Server.. What if the List is already there? what if the List is partially there? What if the Title is used by another List. That is why Client Side code is (eventually) better. Client Side code will give you an Error response.. Back-End code fails after a (dumb) Push – Danny '365CSI' Engelman May 16 '17 at 9:27
0

If you want to create a simple custom list then also you have to add schema.xml to your project, if you don't want other fields then don't add those fields but you have to add schema.xml in order to create a list.

<List xmlns:ows="Microsoft SharePoint" Title="Basic List" EnableContentTypes="TRUE" FolderCreation="FALSE"  Direction="$Resources:Direction;" Url="Lists/Basic List" BaseType="0"  xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<ContentTypes>
  <ContentTypeRef 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="/_layouhttps://devofficecdn.azureedge.net/sharepointdocumentation/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="LinkTitle"></FieldRef>          
    </ViewFields>        
  </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>
  • Hi i tried ur solution but no luck. Updated the Question with the schema.xml and updated the package-solution.json as per the new changes – TARUN May 16 '17 at 9:14

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.