-
Notifications
You must be signed in to change notification settings - Fork 163
Open
Description
Hello,
I would like to create a document library based on a template and add an existing site column to the library. My approach is to pass the ID of the site column to the template using a parameter. Unfortunately, this does not work; it only works if I hardcode the site column ID into the template!
Here my sample template:
<?xml version="1.0"?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2021/03/ProvisioningSchema">
<pnp:Preferences Generator="PnP.Framework, Version=1.9.1.0, Culture=neutral, PublicKeyToken=0d501f89f11b748c" >
</pnp:Preferences>
<pnp:Templates ID="CONTAINER-TEMPLATE-CONTOSO">
<pnp:ProvisioningTemplate ID="LIBRARY-TEMPLATE-TEST" Version="1" BaseSiteTemplate="STS#3" Scope="RootSite">
<pnp:Lists>
<pnp:ListInstance Title="{parameter:LibraryName}" Description="" TemplateType="101" Url="{parameter:LibraryUrl}" EnableVersioning="true" >
<!-- Add existing site column -->
<pnp:FieldRefs>
<pnp:FieldRef ID="{parameter:DocumentCategoryFieldId}" Name="BTDocumentCategory" DisplayName="Category" />
</pnp:FieldRefs>
<!-- Add field to default view -->
<pnp:Views>
<pnp:View Title="All Documents" DefaultView="true" Paged="TRUE" ViewType2="HTML" DisplayName="All Documents">
<pnp:ViewFields>
<pnp:FieldRef Name="DocIcon" />
<pnp:FieldRef Name="LinkFilename" />
<pnp:FieldRef Name="Modified" />
<pnp:FieldRef Name="Editor" />
<pnp:FieldRef Name="BTDocumentCategory" />
</pnp:ViewFields>
</pnp:View>
</pnp:Views>
</pnp:ListInstance>
</pnp:Lists>
</pnp:ProvisioningTemplate>
</pnp:Templates>
</pnp:Provisioning>
This is the call to execute the template provisioning
$param = @{ "LibraryName"="test19"; "LibraryUrl"="test19"; "DocumentCategoryFieldId"="060cf9a8-a593-4066-95df-a28579bdc092" }
Invoke-PnPSiteTemplate -Path ".\test.xml" -Parameters $param
It works when I hardcode the ID here
<!-- Add existing site column -->
<pnp:FieldRefs>
<pnp:FieldRef ID="060cf9a8-a593-4066-95df-a28579bdc092" Name="BTDocumentCategory" DisplayName="Category" />
</pnp:FieldRefs>
Note: it doesn't matter if I put the ID in curly brackets or not. {060cf9a8-a593-4066-95df-a28579bdc092} or 060cf9a8-a593-4066-95df-a28579bdc092 both works
Metadata
Metadata
Assignees
Labels
No labels