Forum Discussion
gadagottiraj
Feb 14, 2020Brass Contributor
is there a way to bind list column to an content type in PNP Schema?
Hello Everyone, I have created a site content type called "test" and I have a list called "clients" at which i have added this content type as default content type. and then I have added all the ...
- Feb 14, 2020
Hey gadagottiraj,
Not sure if it will help since you told you don't want to create a site column, but I had a similar problem with content type and I was to find create it using provision.
In my case, I needed to add a column to Site Pages. My solution was to create a site column with the
Field tag inside the pnp:SiteFields tag, then reference it in both the Site Page Content Type and the Site Pages library. Here's a quick example:<pnp:SiteFields> <Field Type="Lookup" DisplayName="FieldName" ID="{fieldID}" SourceID="{{siteid}}" .../> </pnp:SiteFields> ... <pnp:ContentTypes> <pnp:ContentType ID="xxxx" Name="Site Page" ...> <pnp:FieldRefs> <pnp:FieldRef ID="fieldID" Name="FieldName" UpdateChildren="false" /> </pnp:FieldRefs> ... </pnp:ContentType> </pnp:ContentTypes>This way, you can create a site column, include it in your custom content type, and insert your content type in your list. Let me know if you need any help.
Carlos_Marins
Feb 14, 2020Iron Contributor
Hey gadagottiraj,
Not sure if it will help since you told you don't want to create a site column, but I had a similar problem with content type and I was to find create it using provision.
In my case, I needed to add a column to Site Pages. My solution was to create a site column with the
Field tag inside the pnp:SiteFields tag, then reference it in both the Site Page Content Type and the Site Pages library. Here's a quick example:
<pnp:SiteFields>
<Field Type="Lookup" DisplayName="FieldName" ID="{fieldID}" SourceID="{{siteid}}" .../>
</pnp:SiteFields>
...
<pnp:ContentTypes>
<pnp:ContentType ID="xxxx" Name="Site Page" ...>
<pnp:FieldRefs>
<pnp:FieldRef ID="fieldID" Name="FieldName" UpdateChildren="false" />
</pnp:FieldRefs>
...
</pnp:ContentType>
</pnp:ContentTypes>
This way, you can create a site column, include it in your custom content type, and insert your content type in your list. Let me know if you need any help.