SOLVED

PnP Provisioning engine - Apply to list template type

Copper Contributor

Is there a way using the PnP provisioning engine, to apply configuration to all lists of a particular template type in a site? i.e. I have a specific configuration that will apply to all document libraries in a site. As far as I can see all list instances specified in the template file need a hard coded name.

 

It'd also be good to be able to specify if a list doesn't exist, it just skips over that bit instead of trying to create it.

5 Replies

You could create a extention to your pnp project which genericly changes the settings of your lists.

best response confirmed by Paul Quirk (Copper Contributor)
Solution

I would recommend a different approach.

 

Instead of trying to apply your changes with one call to the template, add a parameter to the template for the list name and use the parameter in the template element where it is attempting to apply the change.  

 

Then use the site context to get all lists in the web site, test each one for its type (so you are only working on Document Libraries), and then apply the template to those that match your criteria, passing in the name of the "current" doc lib. 

 

Basically, loop through all the lists in your site, calling applytemplate() multiple times, once for each doc lib you want to change.

Thanks for that. That is pretty much the approach I'd come up with.

I've created a provisioning template with the settings I want that has a parameter "ListTitle" for the ListInstance title parameter. It works excellent for PowerShell, which is one of the use cases I'm using it in.

Just struggling how to do the same in CSOM.
... and I think I got CSOM bit too.

Once I have the template object, I can add the Parameter to that, as suggested here: https://github.com/SharePoint/PnP-Sites-Core/issues/831
Generally works pretty well. But what I've kind of found is that running applytemplate multiple times on the same web takes a while. I'm trying to find a way to dynamically add the existing lists in a web to the template to apply any required settings to them.
1 best response

Accepted Solutions
best response confirmed by Paul Quirk (Copper Contributor)
Solution

I would recommend a different approach.

 

Instead of trying to apply your changes with one call to the template, add a parameter to the template for the list name and use the parameter in the template element where it is attempting to apply the change.  

 

Then use the site context to get all lists in the web site, test each one for its type (so you are only working on Document Libraries), and then apply the template to those that match your criteria, passing in the name of the "current" doc lib. 

 

Basically, loop through all the lists in your site, calling applytemplate() multiple times, once for each doc lib you want to change.

View solution in original post