SOLVED

is there a way to bind list column to an content type in PNP Schema?

%3CLINGO-SUB%20id%3D%22lingo-sub-1173206%22%20slang%3D%22en-US%22%3Eis%20there%20a%20way%20to%20bind%20list%20column%20to%20an%20content%20type%20in%20PNP%20Schema%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1173206%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Everyone%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20created%20a%20site%20content%20type%20called%20%22test%22%20and%20I%20have%20a%20list%20called%20%22clients%22%20at%20which%20i%20have%20added%20this%20content%20type%20as%20default%20content%20type.%20and%20then%20I%20have%20added%20all%20the%20list%20column%20to%20it.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20I%20export%20the%20template%20and%20apply%20for%20new%20site%2C%20list%20columns%20are%20not%20properly%20bind%20to%20that%20default%20content%20type.%20Because%20of%20this%20we%20need%20to%20manually%20add%20them%20in%20that%20content%20type%20again.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENote%3A%20We%20don't%20want%20to%20create%20these%20columns%20as%20site%20columns%20as%20we%20have%20different%20requirement.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20failed%20to%20make%20this%20work%2C%20can%20someone%20help%20me%20out%20to%20see%20something%20like%20below%20when%20we%20use%20template%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%221.PNG%22%20style%3D%22width%3A%20883px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F171180i0DB08991424662A4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%221.PNG%22%20alt%3D%221.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPNP%20Schema%20that%20I%20have%20exported%20is(not%20sure%20how%20to%20bind%20it%20for%20each%20column%20here)%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CFONT%20color%3D%22%233366FF%22%3E%3CEM%3E%3CFIELDS%3E%3C%2FFIELDS%3E%3C%2FEM%3E%3C%2FFONT%3E%3C%2FDIV%3E%3CDIV%3E%3CFONT%20color%3D%22%233366FF%22%3E%3CEM%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3CFIELD%3E%3C%2FFIELD%3E%3C%2FEM%3E%3C%2FFONT%3E%3C%2FDIV%3E%3CDIV%3E%3CDIV%3E%3CDIV%3E%3CFONT%20color%3D%22%233366FF%22%3E%3CEM%3E%3C%2FEM%3E%3C%2FFONT%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CDIV%3E%3CDIV%3E%3CDIV%3E%3CFONT%20color%3D%22%233366FF%22%3E%3CEM%3E%3C%2FEM%3E%3C%2FFONT%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3EField%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EType%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22Note%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EDisplayName%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22Branch_0%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EStaticName%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22od3a075fe9fd48b6ac342fa380061499%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EName%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22od3a075fe9fd48b6ac342fa380061499%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EID%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22%7B7ede2f99-12a8-448b-ae1d-99c3a23cb446%7D%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EShowInViewForms%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22FALSE%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3ERequired%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22FALSE%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EHidden%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22TRUE%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3ECanToggleHidden%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22TRUE%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EColName%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22ntext2%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3ERowOrdinal%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%220%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%2F%26gt%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1173206%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1174326%22%20slang%3D%22en-US%22%3ERe%3A%20is%20there%20a%20way%20to%20bind%20list%20column%20to%20an%20content%20type%20in%20PNP%20Schema%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1174326%22%20slang%3D%22en-US%22%3E%3CP%3EHey%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F288162%22%20target%3D%22_blank%22%3E%40gadagottiraj%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENot%20sure%20if%20it%20will%20help%20since%20you%20told%20you%20don't%20want%20to%20create%20a%20site%20column%2C%20but%20I%20had%20a%20similar%20problem%20with%20content%20type%20and%20I%20was%20to%20find%20create%20it%20using%20provision.%3C%2FP%3E%3CP%3EIn%20my%20case%2C%20I%20needed%20to%20add%20a%20column%20to%20Site%20Pages.%20My%20solution%20was%20to%20create%20a%20site%20column%20with%20the%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CSPAN%3E%3CSPAN%3EField%20tag%20inside%20the%26nbsp%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%3Epnp%3C%2FSPAN%3E%3CSPAN%3E%3A%3C%2FSPAN%3E%3CSPAN%3ESiteFields%20tag%2C%20then%20reference%20it%20in%20both%20the%20Site%20Page%20Content%20Type%20and%20the%20Site%20Pages%20library.%20Here's%20a%20quick%20example%3A%3C%2FSPAN%3E%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3CSITEFIELDS%3E%0A%20%20%20%20%20%20%20%20%3CFIELD%20type%3D%22Lookup%22%20displayname%3D%22FieldName%22%20id%3D%22%7BfieldID%7D%22%20sourceid%3D%22%7B%7Bsiteid%7D%7D%22%20...%3D%22%22%3E%3C%2FFIELD%3E%0A%3C%2FSITEFIELDS%3E%0A...%0A%20%20%20%20%20%20%3CCONTENTTYPES%3E%0A%20%20%20%20%20%20%20%20%3CCONTENTTYPE%20id%3D%22xxxx%22%20name%3D%22Site%20Page%22%20...%3D%22%22%3E%0A%20%20%20%20%20%20%20%20%20%20%3CFIELDREFS%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CFIELDREF%20id%3D%22fieldID%22%20name%3D%22FieldName%22%20updatechildren%3D%22false%22%3E%3C%2FFIELDREF%3E%0A%20%20%20%20%20%20%20%20%20%20%3C%2FFIELDREFS%3E%0A%20%20%20%20%20%20%20%20%20%20...%0A%20%20%20%20%20%20%20%20%3C%2FCONTENTTYPE%3E%0A%20%20%20%20%20%20%3C%2FCONTENTTYPES%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EThis%20way%2C%20you%20can%20create%20a%20site%20column%2C%20include%20it%20in%20your%20custom%20content%20type%2C%20and%20insert%20your%20content%20type%20in%20your%20list.%20Let%20me%20know%20if%20you%20need%20any%20help.%3C%2FDIV%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

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 list column to it. 

 

When I export the template and apply for new site, list columns are not properly bind to that default content type. Because of this we need to manually add them in that content type again. 

 

Note: We don't want to create these columns as site columns as we have different requirement. 

 

I have failed to make this work, can someone help me out to see something like below when we use template? 

1.PNG

 

PNP Schema that I have exported is(not sure how to bind it for each column here): 

 

<pnp:Fields>
            <Field Type="Note" DisplayName="ManagedService_0" ContentTypeID="0x0100D9A13215F07E8147B12EFE0E4F938757" StaticName="hb203cdb4b95456c904d4fac98c48c7f" Name="hb203cdb4b95456c904d4fac98c48c7f" ID="{2eca7d5d-9518-4c40-8274-b6815d41fcdb}" ShowInViewForms="FALSE" Required="FALSE" Hidden="TRUE" CanToggleHidden="TRUE" ColName="ntext3" RowOrdinal="0" />
</Field>
</pnp:Fields>
            <Field Type="Note" DisplayName="Branch_0" StaticName="od3a075fe9fd48b6ac342fa380061499" Name="od3a075fe9fd48b6ac342fa380061499" ID="{7ede2f99-12a8-448b-ae1d-99c3a23cb446}" ShowInViewForms="FALSE" Required="FALSE" Hidden="TRUE" CanToggleHidden="TRUE" ColName="ntext2" RowOrdinal="0"  />
1 Reply
Highlighted
Best Response confirmed by gadagottiraj (Occasional Contributor)
Solution

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.