<CharlieDigital/> Programming, Politics, and uhh…pineapples


Folders and Nested Folders in ListInstances

Posted by Charles Chen

This took me about 3 hours to figure out so I figure it was worth sharing.

First, I assumed that it was possible given that the .stp file export of a custom list with folders and nested folders seem to work fine.  Online, the feedback seems to be a bit different and my early results seemed to confirm it.  However, I persisted and after several (and I mean several) tries, I finally got it working.

So I share with you the magic sauce for those times when you want to seed your deployment with hierarchical data.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListInstance Title="Seed Data"
      Description="Seed data">
                  <Field Name="ID">1</Field>
                  <Field Name="ContentType">Country</Field>
                  <Field Name="Title">USA</Field>
                  <Field Name="FSObjType">1</Field>
                  <Field Name="ID">2</Field>
                  <Field Name="ContentType">State</Field>
                  <Field Name="Title">New Jersey</Field>
                  <Field Name='FileDirRef'>USA</Field>
                  <Field Name="FSObjType">1</Field>
                  <Field Name="ID">3</Field>
                  <Field Name="ContentType">County</Field>
                  <Field Name="Title">Mercer</Field>
                  <Field Name="FileDirRef">USA/New Jersey</Field>
                  <Field Name="FSObjType">0</Field>

Yes, it was a pretty painful experience to get this figured out, but it was definitely worth it.

Filed under: SharePoint 2 Comments