Skip to content

Fix for issue 1229 to enhance the list level content type in the provisioning engine#1233

Open
wuxiaojun514 wants to merge 3 commits into
pnp:devfrom
wuxiaojun514:contenttype_binding_enhancement
Open

Fix for issue 1229 to enhance the list level content type in the provisioning engine#1233
wuxiaojun514 wants to merge 3 commits into
pnp:devfrom
wuxiaojun514:contenttype_binding_enhancement

Conversation

@wuxiaojun514
Copy link
Copy Markdown

@wuxiaojun514 wuxiaojun514 commented Apr 17, 2026

This is my first PR here.
Please correct me if I miss something or misunderstand something.

Goal

This PR is mainly for issue #1229 and additionally make provisioning engine also support list content type level ClientSideComponent Attributes

Current Problem in provisioning list level content types

Right now our provisioning engine won't export the field ref information on list level content type. Which means if your customized list content type don't have the same settings (field ref, the order of fields, whether the field is reqired/optional/hidden) as its parent level, the provisioning engine won't handle it. (issue #1229 )

Also it won't handle the list content type level clientside component properties (the properties for Form Customizer)

The Changes I did

I did quite a lot changes, I will try to go through them clearly.

Model side

I extended the existing ContentTypeBinding class under list instance with FieldRef collection and client side component attributes (DisplayFormClientSideComponentId/DisplayFormClientSideComponentProperties/NewFormClientSideComponentProperties...)

The exported template will be like this

<pnp:ContentTypeBinding ContentTypeID="0x010060F86BBFE48A3F49A58601F60F821759" DisplayFormClientSideComponentId="" DisplayFormClientSideComponentProperties="" NewFormClientSideComponentProperties="" EditFormClientSideComponentId="" EditFormClientSideComponentProperties="">
              <pnp:FieldRefs>
                <pnp:FieldRef ID="fa564e0f-0c70-4ab9-b863-0177e6ddd247" Required="true" UpdateChildren="false" />
                <pnp:FieldRef ID="da2f5d99-4f35-4b25-b8f3-1a7092f55aaf" UpdateChildren="false" />
                <pnp:FieldRef ID="a89bfa3e-48a8-4f5d-8736-3d9bcaa20128" Required="true" UpdateChildren="false" />
                <pnp:FieldRef ID="8c4aaefe-7cca-4938-931e-01422c0036ac" UpdateChildren="false" />
                <pnp:FieldRef ID="22c6c640-3565-41c8-a070-e7e7c61b609c" UpdateChildren="false" />
                <pnp:FieldRef ID="59d3d705-cdd8-4678-8bb1-ab89929ffc19" UpdateChildren="false" />
                <pnp:FieldRef ID="6bd0e653-3e3d-477b-87e1-1f19e400fd37" UpdateChildren="false" />
                <pnp:FieldRef ID="fa7d2c2a-358e-4945-b76b-cb45a970dd0c" UpdateChildren="false" />
                <pnp:FieldRef ID="9ca9a09c-c430-480d-91b2-05c7f5e68fbd" Hidden="true" UpdateChildren="false" />
                <pnp:FieldRef ID="c042a256-787d-4a6f-8a8a-cf6ab767f12d" UpdateChildren="false" />
                <pnp:FieldRef ID="02fdb5ed-2334-4b93-8a9e-a77dcdf5861f" Hidden="true" UpdateChildren="false" />
                <pnp:FieldRef ID="f3b0adf9-c1a2-4b02-920d-943fba4b3611" Hidden="true" UpdateChildren="false" />
                <pnp:FieldRef ID="8f6b6dd8-9357-4019-8172-966fcd502ed2" Hidden="true" UpdateChildren="false" />
                <pnp:FieldRef ID="3bffd1bf-6d85-430d-bc41-64fbe0d3e3e5" Hidden="true" UpdateChildren="false" />
              </pnp:FieldRefs>
</pnp:ContentTypeBinding>
...

Schema side

I created a new version of provisioning xml schema (src/lib/PnP.Framework/Provisioning/Providers/Xml/ProvisioningSchema-2026-04.xsd) .
I added the highlighted properties on the new version
image

Changes on Extract Template

I modified ExtractContentTypes method in ObjectListInstance.cs, now it will also fetch fieldlink information and client side component properties on the list level content type

Changes on Apply Template

I created a new method called ProcessListContentTypeBindingSettings in ObjectListInstance.cs to handle all new processes (add/update fieldlink and its hidden/required property , change the sort order of fields) for list content type. This method will be called after ProcessFields method to make sure all list fields has been created.

Note: it won't handle delete fieldlink if template don't have the field in list content type

Test Side

I added new test sample xml. This sample test template will be used in test case CanApplyListInstanceWithListContentTypeFieldRefSettings in ObjectListInstanceTests.cs to verify whether list content type level's field will be added properly.

I added another test case to debug export template in list instance object handler (just for debug purpose, I can remove this test case if you want).

I added a new "XMLSerializer Tester" for new schema version : XMLSerializer202604Tests.cs. 99% content are just copied from previous version. I added two new test cases:

  • XMLSerializer_Deserialize_ListInstances_ContentTypeBindingClientSideComponentProperties_2604NewAdded for testing list content type client side component related properties
  • XMLSerializer_Deserialize_ListInstances_ContentTypeBindingFieldRefs_2604NewAdded for testing list content type level field ref

I am not very clear when and where to add test case. Please guide me if I miss something.

Others

I got error here when I tried to apply my template which contains taxonomy field.
Github Copilot suggested me to change use this way to convert the field to taxonomy field (Github Copilot said this way will be more safe...)

image

I tried to put PnP.Framework.dll into PnP Powershell Project, it seems working well (Did several list provisioning test)

Please let me know if you have any concern on this PR.
Thank you.

tony wu added 3 commits April 17, 2026 14:40
1. Add FieldRefs on ContentTypeBinding so Provisioning engine will handle list level content type fieldLink (issue pnp#1229)
2. Add "ContentTypeClientSideComponentAttributes" on ContentTypeBinding so the provisioning engine will handle list content type level ClientSideComponent properties (for FormCustomizer)
remove unnecessary resolver class
- Use 2604 as default version in PnPSchemaFormatter
- Better show provisioning status by adding the log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant