powershell icon indicating copy to clipboard operation
powershell copied to clipboard

[FEATURE] Get-PnPSiteTemplate - add ability to exclude builtin fields

Open wilecoyotegenius opened this issue 3 years ago • 4 comments

Is your feature request related to a problem? Please describe. It would be nice if there was an option to exclude built-in fields from provisioning template. I often need to declutter exported template with builtin fields, as all I really need are custom ones.

Describe the solution you'd like Have either:

  • a flag (ExcludeBuiltinFields) or
  • a parameter allowing to specify only those field groups that should be exported (FieldGroups - similar to ContentTypeGroups). added to Get-PnPSiteTemplate cmdlet

Describe alternatives you've considered I did not find a way to do it using currently existing cmdlets.

Additional context If this feature is approved, I'd be happy to implement this and provide a PR

wilecoyotegenius avatar Jul 13 '21 22:07 wilecoyotegenius

Hello @wilecoyotegenius , we already filter out most of the OOTB fields , for example - Author, Editor, Modified etc.
Are there any other fields that you want to exclude ?

gautamdsheth avatar Jul 22 '21 11:07 gautamdsheth

let me chime in here: I just tried to apply a template where the source-site had the documentsID-Feature enabled, which introduced additional columns. When I tried to apply them to the target set, it gives me access denied. That is the same if the target already has the documentID-feature enabled (columns already present) or never had the feature enabled (I tested with a completely fresh target site). so these columns should be included or maybe make a case for you to implement custom exclusion. I worked around by commenting them in the xml, but its pretty unpleasant...

  • _dlc_DocId
  • _dlc_DocIdUrl
  • _dlc_DocIdPersistId

RichieRoxx avatar Oct 25 '21 09:10 RichieRoxx

I just noticed today, that if we have the site collection app catalog activated in the site collection, quite a lot of fields will be added to the template as well:

  • AppSupportedLocales
  • AppImageURL1
  • AppMetadataLocale
  • [...]

I personally think that the second proposition will be ideal, to introduce a parameter "FieldGroups"

TashunkoWitko avatar Nov 15 '21 15:11 TashunkoWitko

I have had this issue since starting to work with PnP.

There hasn't been an instance whereby exporting fields hasn't called for culling of the generated xml - and by culling, I mean by deleting any fields in the group _hidden. If we don't do this, we get a lot of errors ranging from duplicate field issues all the way to "Unknown Error", but if we remove all fields in the _hidden group, the template works a treat!

Could the _hidden group be automatically removed from the export?

As @TashunkoWitko said above, having a "FieldGroups" parameter to control the fields to include would be great too. In this case, if we choose specific content type groups and we haven't married up the field groups accordingly, the template should still include those fields as dependencies.

tandrasi avatar Oct 19 '23 03:10 tandrasi