How to associate a Form Customizer extension with a content type?

Parekh, Soham 40 Reputation points
2023-10-22T17:48:33.11+00:00

Hi,

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:

  1. Is it possible to use this extension to customize the form experience at a document library level?
  2. If yes, how?
Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2023-10-25T01:30:10.0633333+00:00

    Hi@Parekh, Soham

    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:

    1. Is it possible to use this extension to customize the form experience at a document library level?
    2. 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:

    1. PowerShell or M365 CLI: https://pnp.github.io/script-samples/spo-add-formextension-to-list/README.html?tabs=pnpps
    2. A custom util webpart someone wrote for this: https://www.youtube.com/watch?v=1I0uE-IiLEM
    3. 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!


2 additional answers

Sort by: Most helpful
  1. Anonymous
    2023-10-23T06:05:57.74+00:00

    Hi @Parekh, Soham

    Yes, it is possible to use a form customizer extension to customize the form experience at a document library level

    But from a programming perspective, this is very complicated. You need to have a certain coding foundation and be familiar with programming.

    It is recommended that you use power apps to build forms

    As a low-code development platform, power apps have a much lower learning cost than conventional programming and are very user-friendly.

    It can be integrated with SharePoint and I also found a detailed tutorial for your reference.

    Here is link for your reference:

    https://powerusers.microsoft.com/t5/Webinars-and-Video-Gallery/Customize-SharePoint-Document-Library-Form-using-Power-Apps/td-p/1341442


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards

    Cheng Feng


  2. Parekh, Soham 40 Reputation points
    2023-10-24T20:52:00.1366667+00:00

    I figured this out.

    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:

    1. PowerShell or M365 CLI: https://pnp.github.io/script-samples/spo-add-formextension-to-list/README.html?tabs=pnpps
    2. A custom util webpart someone wrote for this: https://www.youtube.com/watch?v=1I0uE-IiLEM
    3. 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 set_property functions to set the properties I needed (you can copy them from powershell example above)

    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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.