1

Working on Sharepoint Online with PnP Provisioning Schema of 2015/12 (here). When provisioning my website with Libraries, I'm stepping into some error that i don't understand.

What i have :

a web site, and a XML template to provision this website. Here is my .xml :

<?xml version="1.0" encoding="utf-8" ?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2015/12/ProvisioningSchema">
  <pnp:Preferences></pnp:Preferences>
  <pnp:Templates>
    <pnp:ProvisioningTemplate ID="GED_SiteLibProvision">
      <pnp:Lists>
        <pnp:ListInstance Title="Documents projet"
                          Description="Documents partagés entre les différents acteurs du projet (ASI et client)"
                          DocumentTemplate="{site}/documentsprojet/Forms/template.dotx"
                          TemplateType="101"
                          Url="documentsprojet"
                          EnableVersioning="true"
                          EnableMinorVersions="true"
                          MinorVersionLimit="20"
                          MaxVersionLimit="100"
                          DraftVersionVisibility="0"
                          ContentTypesEnabled="true"
                          EnableFolderCreation="true">
          <pnp:ContentTypeBindings>
            <pnp:ContentTypeBinding ContentTypeID="0x010100BBD2E6E36069334ABFD4717B8C2FA4D9" Default="true" />
            <pnp:ContentTypeBinding ContentTypeID="0x010100BBD2E6E36069334ABFD4717B8C2FA4D901"/>
            <pnp:ContentTypeBinding ContentTypeID="0x010100BBD2E6E36069334ABFD4717B8C2FA4D902"/>
          </pnp:ContentTypeBindings>
          <pnp:FieldRefs>
            <pnp:FieldRef ID="77f7534a-f3e1-4ba2-9448-0c5839e571df" Name="NumContrat" DisplayName="N° Contrat" />
            <pnp:FieldRef ID="dc2e725a-788e-4a60-bb85-47880da1e64b" Name="Client" DisplayName="Client" />
            <pnp:FieldRef ID="2cd5d04d-f91a-4e3c-b028-bb38c2081f0c" Name="NomProjet" DisplayName="Nom du projet" />
            <pnp:FieldRef ID="ab065451-14d6-485a-88c3-414c908d50d3" Name="CategoryDescription" DisplayName="Description" />
            <pnp:FieldRef ID="143f59fd-e9e8-4873-96a0-78d5e30e09f4" Name="Theme" DisplayName="Thème" />
            <pnp:FieldRef ID="ced0bc19-02f5-43b6-9f31-9c5e7c8bc5e0" Name="EtatValidation" Required="true" DisplayName="Etat de validation" />
            <pnp:FieldRef ID="34db01b9-a304-45e2-aeac-76fdfaaf7b61" Name="DateReunion" DisplayName="Date de réunion" />
            <pnp:FieldRef ID="c30961f9-d97e-465a-9b86-f2fba78932ba" Name="NumeroCopil" DisplayName="Numéro de copil" />
            <pnp:FieldRef ID="5161a256-0d8f-4805-81b2-13544c347221" Name="DateValidation" DisplayName="Date de validation" />
            <pnp:FieldRef ID="14a098e7-88db-4061-b036-f1a51c0e2511" Name="Module" DisplayName="Module" />
          </pnp:FieldRefs>
          <pnp:FieldDefaults>
            <pnp:FieldDefault FieldName="EtatValidation">Brouillon</pnp:FieldDefault>
            <pnp:FieldDefault FieldName="EtatValidationCR">A valider</pnp:FieldDefault>
          </pnp:FieldDefaults>
        </pnp:ListInstance>
        <pnp:ListInstance Title="Espace privé"
                          Description="Documents internes ASI."
                          DocumentTemplate="{site}/espaceprive/Forms/template.dotx"
                          TemplateType="101"
                          Url="espaceprive"
                          EnableVersioning="true"
                          EnableMinorVersions="true"
                          MinorVersionLimit="20"
                          MaxVersionLimit="100"
                          DraftVersionVisibility="0"
                          ContentTypesEnabled="true"
                           EnableFolderCreation="true">
          <pnp:ContentTypeBindings>
            <pnp:ContentTypeBinding ContentTypeID="0x010100BBD2E6E36069334ABFD4717B8C2FA4D9" Default="true" />
            <pnp:ContentTypeBinding ContentTypeID="0x0120" />
          </pnp:ContentTypeBindings>
          <pnp:FieldRefs>
            <pnp:FieldRef ID="77f7534a-f3e1-4ba2-9448-0c5839e571df" Name="NumContrat" DisplayName="N° Contrat" />
            <pnp:FieldRef ID="dc2e725a-788e-4a60-bb85-47880da1e64b" Name="Client" DisplayName="Client" />
            <pnp:FieldRef ID="2cd5d04d-f91a-4e3c-b028-bb38c2081f0c" Name="NomProjet" DisplayName="Nom du projet" />
            <pnp:FieldRef ID="ab065451-14d6-485a-88c3-414c908d50d3" Name="CategoryDescription" DisplayName="Description" />
            <pnp:FieldRef ID="143f59fd-e9e8-4873-96a0-78d5e30e09f4" Name="Theme" DisplayName="Thème" />
            <pnp:FieldRef ID="ced0bc19-02f5-43b6-9f31-9c5e7c8bc5e0" Name="EtatValidation" Required="true" DisplayName="Etat de validation" />
            <pnp:FieldRef ID="34db01b9-a304-45e2-aeac-76fdfaaf7b61" Name="DateReunion" DisplayName="Date de réunion" />
            <pnp:FieldRef ID="c30961f9-d97e-465a-9b86-f2fba78932ba" Name="NumeroCopil" DisplayName="Numéro de copil" />
            <pnp:FieldRef ID="5161a256-0d8f-4805-81b2-13544c347221" Name="DateValidation" DisplayName="Date de validation" />
            <pnp:FieldRef ID="14a098e7-88db-4061-b036-f1a51c0e2511" Name="Module" DisplayName="Module" />
          </pnp:FieldRefs>
          <pnp:FieldDefaults>
            <pnp:FieldDefault FieldName="EtatValidation">Brouillon</pnp:FieldDefault>
          </pnp:FieldDefaults>
          <pnp:Folders>
            <pnp:Folder Name="01.TEST"/>

          </pnp:Folders>
        </pnp:ListInstance>

      </pnp:Lists>
    </pnp:ProvisioningTemplate>
  </pnp:Templates>
</pnp:Provisioning>

And the function called for Provisioning in my Program.cs :

ProvisionProcessing(newweb, "GED_SiteLibrariesCreation.xml");
    static void ProvisionProcessing(Web web, string template)
            {

                string directory = Path.Combine(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.FullName, "Templates");
                var provisioningProvider = new XMLFileSystemTemplateProvider(directory, string.Empty);
                var provisioningTemplate = provisioningProvider.GetTemplate(template);
                provisioningTemplate.Connector.Parameters[FileConnectorBase.CONNECTIONSTRING] = directory;
                provisioningTemplate.Connector = new FileSystemConnector(System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.FullName, string.Empty);

                //Lancement du provisionning
                web.ApplyProvisioningTemplate(provisioningTemplate);
                web.Context.ExecuteQueryRetry();
            }

What I want :

As you can see, my XML is only a Template to provision my website with 2 Libraries, each having some properties, content type binding and fieldrefs. Now, I would like to create a folder "01. Text" into the second library, "espace privé".

What is the error :

An unhandled exception of type 'System.NullReferenceException' occurred in OfficeDevPnP.Core.dll

Additional information: La référence d'objet n'est pas définie à une instance d'un objet.

-- Edit : Added the call stack -- Here is the callstack i have : Call stack The first line refers to the Provisioning launch in ProvisionProcessing method, aka web.ApplyProvisioningTemplate(provisioningTemplate); The second line refers to the call of this method, with my .xml template in parameters, aka ProvisionProcessing(newweb, "GED_SiteLibrariesCreation.xml");

-- Edit end --

And, well i don't understand this error at all, because i've exactly followed the PnP XML Schema (here for the folder section), AND my website and my libraries are well created, so they can't be null.

What i've tested: I have already tested this template without the folders part, and it is doing great. But strangely the error is not saying the template is invalid, but it occurs at another place...

-- Edit : new tests -- I tried to rewrite my whole list provisioning template to see if there was something wrong with it. First of all, I've erase one of the ListInstance, to work only with one. I added the good attirbutes, ContentTypeBindings,and FieldDefaults (i squizzed the FieldRefs, because finally, with CTBinding you don't need to add them again). Everything works great

But when i add the

<pnp:Folders>
              <pnp:Folder Name="TESTDP"/>
            </pnp:Folders>

I have a new error, really strange, saying that "the List does not exist, the selected page contains a list that does not exist. This may had been deleted by another user.".. But well, the whole point of the XML template is to create/upgrade the list !

-- Edit end --

Can you please help me finding where the error is, why it is happening and how i could fix it, please?

Thanks a lot !

  • Can you please also post stack trace of the exception? Without stack trace it's too difficult to guess what's going on. – Sergei Sergeev Nov 15 '16 at 17:27
  • Hello @Kai, thank for your time. Well, the call stack is not really helpful here (or i don't know how to properly use it) I've added the results of it on my question, and added new tests i ran. Thanks a lot for your time ! – Gaelle Nov 16 '16 at 11:08
  • Sorry, may be I'm not accurate, I'm asking about stack trace for the exception, not call stack of your app. Do you have an access to stack trace of the exception? – Sergei Sergeev Nov 16 '16 at 11:43
  • Also I can recommend you to do some revers engineering - PnP allows you to get template from the site. You can add list, create required folders and then export that template into the file system and see the difference. – Sergei Sergeev Nov 16 '16 at 11:47
  • Ha, well, sorry, i'm not used to VS2015, so i'll have to find the stack trace you're talking about (and in fact, I'm only developping the .xml, I'm not in charge of the code, so sorry if you have to ask me simple things and if i answer totally wrong) I did generate a xml template from my previous site, where i had the exact same list with folders, but the xml template do not mention any folders. Even if i copy/past the .xml section of this List, no folder is generated...Again, thank you for your time @Kai :) – Gaelle Nov 16 '16 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.