1

Hello fellow sharepointers !

I need your help on my provisioning template.

I am creating a new Document library which is bound to a custom content Type. I want to add a whole architecture of folders and unfortunately can't make it work, i don't know why.

What i have :

my XML Template : GED_SiteLibrariesCreation.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_SiteLibrariesCreation">
      <pnp:Lists>
          <pnp:ListInstance Title="Documents projet"
                          Description="Documents partagées entre les acteurs du projet (ASI et client)"
                          TemplateType="101"
                          Url="documentprojet"
                          EnableVersioning="true"
                          EnableMinorVersions="true"
                          MinorVersionLimit="20"
                          MaxVersionLimit="100"
                          DraftVersionVisibility="0"
                          ContentTypesEnabled="true"
                          RemoveExistingContentTypes="true"
                          EnableFolderCreation="true">
            <pnp:ContentTypeBindings>
              <pnp:ContentTypeBinding ContentTypeID="0x010100BBD2E6E36069334ABFD4717B8C2FA4D9" Default="true" />
              <pnp:ContentTypeBinding ContentTypeID="0x010100BBD2E6E36069334ABFD4717B8C2FA4D901"/>
              <pnp:ContentTypeBinding ContentTypeID="0x010100BBD2E6E36069334ABFD4717B8C2FA4D902"/>
            </pnp:ContentTypeBindings>
            <pnp:FieldDefaults>
              <pnp:FieldDefault FieldName="EtatValidation">Brouillon</pnp:FieldDefault>
              <pnp:FieldDefault FieldName="EtatValidationCR">A valider</pnp:FieldDefault>
            </pnp:FieldDefaults>

            <pnp:Folders>
              <pnp:Folder Name="01.TEST">
                  <pnp:Folder Name="0102. TEST"></pnp:Folder>
              </pnp:Folder>

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


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

What do i get :

My list is created or updated, but no folder are created. I have absolutely no error nor output saying something went wrong.

I've followed letter to letter the examples given in the provisioning schema on GitHub

Please, could you give me other examples or a clue on what could go wrong ?

Thanks a lot.

Have a nice day.

  • <pnp:Folder Name="0102. TEST"></pnp:Folder> instead of this, try it as <pnp:Folder Name="0102. TEST"/> – Gautam Sheth Nov 21 '16 at 16:59
  • Hello @GautamSheth, thanks for your reply. I've tested as you said and it is still not working... Thanks for your time anyway, i hope it could help someone else ;) – Gaelle Nov 28 '16 at 13:38
1

I've tried your template and everything works fine for me - folders are created (I deleted ContentTypeBindings since this content types don't exist in my environment).

I can recommend the following:

  1. Make sure you are using latest version of PnP from nuget (I'm using SharePointPnPCoreOnline.2.9.1611.0)

  2. If #1 didn't help, try to remove all ContentTypeBindings like I did (may be that's an issue?)

UPD
So finally, thanks to @Gaelle comment, I was able to reproduce this behavior.
I found that there is a bug in PnP - here is the link to corresponding issue reported October, 20.
Following code will not work for you:

var ctx = new ClientContext("https://sp.sharepoint.com/sites/dev/");
var subweb = ctx.Site.OpenWeb("tests");
ctx.Load(subweb);
ctx.ExecuteQueryRetry();
.....
subweb.ApplyProvisioningTemplate(template);

Besides this one works:

var ctx = new ClientContext("https://sp.sharepoint.com/sites/dev/tests");
ctx.Load(ctx.Web);
ctx.ExecuteQueryRetry();
....
ctx.Web.ApplyProvisioningTemplate(template);

And this is what is the issue about: in the first sample I'm using OpenWeb method and it doesn't work, for second sample I created client context using sub site url and it does work.

For now I think this is the only working workaround for you - construct new client context (don't forget about disposing) for subsite.

  • Hello @Kai, thanks for your comment. Normally my version of SharepointPnpCoreOnline is the good one. But because we are working on Azure, i will check if the packages are good on it. Removing ContentTypeBindings did not work, and it won't be a real solution but only a workaround since we really need custom ContentType to be bound in our Doc Libraries... i'll give a feedback later. – Gaelle Nov 28 '16 at 13:39
  • Hello @Kai I have a request for you : did you test my xml template on a ROOT site or on a WEB site ? (this could really be important). Because we are creating and provisioning this library into a subsite (or website) under or site collection... Thanks a lot for your feedback ! – Gaelle Nov 28 '16 at 16:43
  • @Gaelle: now I see... please take a look at my update – Sergei Sergeev Nov 28 '16 at 17:46
  • THANKS A LOT ! Effectively, rebuilding client context with subweb URL is the solution ! We managed it. And well, i think maybe it is a better practice to reload the right context – Gaelle Nov 29 '16 at 13:38

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.