pnp / pnp/pnpframework

Provisioning Handler Fields Creates subweb fields with existing rootweb ID and InternalName

Open
#400 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
259
Forks
161
Avg merge
10h 33m
Merged PRs (30d)
1

Description

Greetings,

In my opinion this can be categorized as an SharePoint server side bug, but could be avoided by using property "AvailableFields" instead of "Fields".
At src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectField.cs , the property web.Fields is used to check if the ID and InternalName already exists, as Fields and AvailableFields return FieldCollection, using AvailableFields to check for duplicates would be more accurate, unless it is expected to let users add fields using the same ID and InternalName on different structure levels.

The impact:
If you add the subweb SiteField to a content type and then add this contenttype to a list, editing the rootweb SiteField will update the list field (probably because it has a fieldReference to the same ID, but I didn't check the code).
--Edit: Rootweb SiteField and subweb SiteField doesn't have a relationship, so the subweb sitefield that would have precedence simply doesn't.

Steps to Reproduce:
XML:
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2021/03/ProvisioningSchema">
<pnp:Templates ID="CONTAINER-TEMPLATE-251B9819BA4B44BD95EC26C3F15EFB8F">
<pnp:ProvisioningTemplate ID="TEMPLATE-708700F5E7E74276909FB0F7144EDD56" BaseSiteTemplate="STS#3" Scope="Web">
pnp:SiteFields
< Field Type="Boolean" DisplayName="Notification Sent" EnforceUniqueValues="FALSE" Indexed="FALSE" Group="WFExtras" ID="{6d46b73e-6593-4577-b086-4560e39682fb}" SourceID="{d951647c-9518-4d50-a3c7-5a60da54140b}" StaticName="TP_UserSent" Name="TP_UserSent" CustomFormatter="" Required="FALSE" ColName="bit2" RowOrdinal="0">
0
< /Field>
</pnp:SiteFields>
</pnp:ProvisioningTemplate>
</pnp:Templates>
</pnp:Provisioning>

Using PNPFramework through PNP.PowerShell:
Invoke-PnPSiteTemplate -Connection $rootSiteConn -ProvisionFieldsToSubWebs -Handlers Fields
Invoke-PnPSiteTemplate -Connection $subwebSiteConn -ProvisionFieldsToSubWebs -Handlers Fields

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/lib/PnP.Framework/Provisioning/ObjectHandlers/ObjectField.cs and inspect how web.Fields checks existing IDs and InternalNames during field provisioning. Reproduce the behavior with the XML template and the two Invoke-PnPSiteTemplate commands, comparing Fields with AvailableFields. Done means rootweb and subweb fields with the same identifiers are handled without the reported list-field conflict.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.