
I'm glad to hear you solve the problem ,if you have any issue about SharePoint, you are welcome to raise a ticket in this forum.
By the way, since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others." and according to the scenario introduced here: Answering your own questions on Microsoft Q&A, I would make a brief summary of this thread:
[How to associate a Form Customizer extension with a content type?]
Issue Symptom:
I'm building a form customizer extension, and I have it working with a demo list I've created on my site. However, I'd like to use it on a document library form by associating it with a content type. I believe this is possible from the documentation:
Form customizers are SharePoint Framework components giving you an option to override the form experience in a list or library level by associating the component to the used content type.
However, the documentation only includes examples for setting up the dev instance with a list, and not a content type. Can someone tell me whether:
- Is it possible to use this extension to customize the form experience at a document library level?
- If yes, how?
Solution:
To use a form customizer extension in a document library, it needs to be associated with a content ID. There's a few ways to do this:
- PowerShell or M365 CLI: https://pnp.github.io/script-samples/spo-add-formextension-to-list/README.html?tabs=pnpps
- A custom util webpart someone wrote for this: https://www.youtube.com/watch?v=1I0uE-IiLEM
- Using the REST APIs: This is what I went with. I used the vgrem Python lib to get a content type by name, and then used the functions to set the properties I needed (you can copy them from powershell example above)
set_property
You can confirm this works by creating a new content type, adding the properties as mentioned above, and then creating a document library with a custom content type column.
You could click the "Accept Answer" button for this summary to close this thread, and this can make it easier for other community member's to see the useful information when reading this thread. Thanks for your understanding!