0

I'm using PNP provisioning templates.

I have created a template for the root site that creates columns and content types.

In the subweb, I have another template that creates 2 list instances. One list instance is just a list with a title field. The second ListInstance has applied the content type created at the root site, but on this list I have also created a lookup field to the first list instance.

How do I add the list field to the content type on that list with the PNP Provisioning template engine? Or does this have do be done in Powershell?

<pnp:ListInstance Title="My List" EnableAttachments="false" OnQuickLaunch="true" Description="" DocumentTemplate="" TemplateType="100" Url="Lists/My List" MinorVersionLimit="0" MaxVersionLimit="0" DraftVersionVisibility="0" TemplateFeatureID="00bfea71-de22-43b2-a848-c05709900100" ContentTypesEnabled="true" EnableFolderCreation="false" DefaultDisplayFormUrl="{site}/Lists/My List/DispForm.aspx" DefaultEditFormUrl="{site}/Lists/My List/EditForm.aspx" DefaultNewFormUrl="{site}/Lists/My List/NewForm.aspx" ImageUrl="/_layouts/15/images/itgen.png?rev=44" IsApplicationList="false" ValidationFormula="" ValidationMessage="">
              <pnp:ContentTypeBindings>
                <pnp:ContentTypeBinding ContentTypeID="0x01007D8DB186841AFD4FA979B7347BDD586C" Default="true" />
                <pnp:ContentTypeBinding ContentTypeID="0x0120" />   
                <pnp:ContentTypeBinding ContentTypeID="0x01" Remove="true" />
              </pnp:ContentTypeBindings>
              <pnp:Views>
                <View Name="{B4D4F64C-7D45-47EC-B5C9-91B6191C07DE}" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" DisplayName="All Items" Url="{site}/Lists/My List/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/generic.png?rev=44">
                  <Query>
                    <OrderBy>
                      <FieldRef Name="ID" />
                    </OrderBy>
                  </Query>
                  <ViewFields>
                    <FieldRef Name="MyColumn1" />
                    <FieldRef Name="MyColumn2" />
                    <FieldRef Name="DateSent" />
                  </ViewFields>
                  <RowLimit Paged="TRUE">30</RowLimit>
                  <Aggregations Value="Off" />
                  <JSLink>clienttemplates.js</JSLink>
                </View>
              </pnp:Views>
              <pnp:Fields>
                <Field Type="LookupMulti" DisplayName="First List" Required="TRUE" EnforceUniqueValues="FALSE" List="{listid:First List}" ShowField="Title" Mult="TRUE" Sortable="FALSE" UnlimitedLengthInDocumentLibrary="FALSE" RelationshipDeleteBehavior="None" ID="{811990de-5c2f-4199-9723-21e9d337e521}" SourceID="{{listid:First List}}" StaticName="Column_x0020_FirstList" Name="Column_x0020_FirstList" ColName="int1" RowOrdinal="0" />
              </pnp:Fields>
              <pnp:FieldRefs>
                <pnp:FieldRef ID="9a98837d-8099-4406-92ff-8920107d0c35" Name="MyColumn1" />
                <pnp:FieldRef ID="a257177e-6093-4125-8aba-bb11504f74f2" Name="MyColumn12" />
                <pnp:FieldRef ID="69d5c9f8-9031-4347-99e6-be6c55b8aab8" Name="DateSent" />
              </pnp:FieldRefs>
            </pnp:ListInstance>

With the above template, the list get's created, attaches the content type, and creates the lookup field, but the lookup field isn't part of the list content type, therefore I have to do that step manually. Otherwise that lookup column isn't available when you click "New" on the list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.