Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listinstance url property ignored when TemplateFeatureID is present #1806

Closed
waaromikniet opened this issue Jun 8, 2018 · 29 comments
Closed

Listinstance url property ignored when TemplateFeatureID is present #1806

waaromikniet opened this issue Jun 8, 2018 · 29 comments
Assignees

Comments

@waaromikniet
Copy link

@waaromikniet waaromikniet commented Jun 8, 2018

Category

[x] Bug
[ ] Enhancement

Environment

[x] Office 365 / SharePoint Online
[ ] SharePoint 2016
[ ] SharePoint 2013

We have migrated our PNP-Core library from January 2018 to May 2018 and we see a different behavior in creating list with our template.

Expected or Desired Behavior

When I apply a template for a list instance and I provide a URL property that is different from the title property I want the list to be created with that url. We do this to prevent spaces in our list URL.

Observed Behavior

I have the following list instance template:

<?xml version="1.0"?> <pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2018/05/ProvisioningSchema"> <pnp:Preferences Generator="OfficeDevPnP.Core, Version=2.22.1801.0, Culture=neutral, PublicKeyToken=null" /> <pnp:Templates ID="CONTAINER-TEMPLATE"> <pnp:ProvisioningTemplate ID="TEMPLATE-PROCES" Version="1" BaseSiteTemplate="STS#0" Scope="Web"> <pnp:Lists> <pnp:ListInstance Title="Procedures en templates" Description="" DocumentTemplate="{site}/ProceduresEnTemplates/Forms/template.dotx" OnQuickLaunch="true" TemplateType="101" Url="ProceduresEnTemplates" EnableVersioning="true" MinorVersionLimit="0" MaxVersionLimit="10" DraftVersionVisibility="0" TemplateFeatureID="00bfea71-e717-4e80-aa17-d0c71b360101" ContentTypesEnabled="true" EnableAttachments="false" EnableFolderCreation="false" DefaultDisplayFormUrl="{site}/ProceduresEnTemplates/Forms/DispForm.aspx" DefaultEditFormUrl="{site}/ProceduresEnTemplates/Forms/EditForm.aspx" DefaultNewFormUrl="{site}/ProceduresEnTemplates/Forms/Upload.aspx" ImageUrl="/_layouts/15/images/itdl.png?rev=44" ValidationFormula="" ValidationMessage=""> <pnp:ContentTypeBindings> <pnp:ContentTypeBinding ContentTypeID="0x010100B6306814800C5D498ABECD7DF497F4C203" Default="true" /> <pnp:ContentTypeBinding ContentTypeID="0x010100B6306814800C5D498ABECD7DF497F4C204" /> <pnp:ContentTypeBinding ContentTypeID="0x010100B6306814800C5D498ABECD7DF497F4C205" /> <pnp:ContentTypeBinding ContentTypeID="0x010100B6306814800C5D498ABECD7DF497F4C206" /> <pnp:ContentTypeBinding ContentTypeID="0x0120" /> <pnp:ContentTypeBinding ContentTypeID="0x0101" Remove="true" /> </pnp:ContentTypeBindings> <pnp:Views> <View Name="{CB49226A-05A7-4A0B-B8CB-0C37A8716480}" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" DisplayName="Alle documenten" Url="{site}/ProceduresEnTemplates/Forms/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/dlicon.png?rev=44"> <Query> <OrderBy> <FieldRef Name="Modified" Ascending="FALSE" /> </OrderBy> </Query> <ViewFields> <FieldRef Name="DocIcon" /> <FieldRef Name="LinkFilename" /> <FieldRef Name="Modified" /> <FieldRef Name="Editor" /> </ViewFields> <RowLimit Paged="TRUE">30</RowLimit> <JSLink>clienttemplates.js</JSLink> </View> </pnp:Views> <pnp:FieldRefs> <pnp:FieldRef ID="9cc881a3-4558-4c5a-a66c-871b9f72ae4e" Name="HideFromDelve" DisplayName="HideFromDelve" /> </pnp:FieldRefs> </pnp:ListInstance> </pnp:Lists> </pnp:ProvisioningTemplate> </pnp:Templates> </pnp:Provisioning>

The title is: Procedures en templates
The url is: ProceduresEnTemplates

When I apply this template on my subsite the list is created with title: "Procedures en templates" and the URL: "Procedures%20en%20 templates.

So the url form my template is ignored. The provisioning then crashes on the form templates because the URL doesn't match. There the URL is to be expected without spaces. When I run this code with the PNP library from January this works fine. I looked the objecthandler for list (ObjectListInstance.cs) and I see this code is added in:

if (templateList.TemplateFeatureID != Guid.Empty) { Site site = ((ClientContext)web.Context).Site; var listTemplates = site.GetCustomListTemplates(web); web.Context.Load(listTemplates); web.Context.ExecuteQueryRetry(); var template = listTemplates.SingleOrDefault(t => t.FeatureId == templateList.TemplateFeatureID); if (template != null) { listCreate.ListTemplate = template; } }

I checked my template and I see the in my template I have a TemplateFeatureID present. This is present because the list was created from a stp file in the past. When I export my template I get this TemplateFeatureID. When I remove this attribute my template will provision with the URL I configured in my template.

@wobba wobba self-assigned this Jun 11, 2018
@wobba

This comment has been minimized.

Copy link
Contributor

@wobba wobba commented Jun 11, 2018

There was a change to fix templates to actually work with stp's - which means it will create the list based off the saved list on the site if present. I'll take a look at the code.

@wobba

This comment has been minimized.

Copy link
Contributor

@wobba wobba commented Jul 27, 2018

Hi @waaromikniet ,
I tested this just now with the latest version using the below template, without an issue. Could you please re-verify if it's still an issue?

<?xml version="1.0"?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2018/05/ProvisioningSchema">
	<pnp:Preferences Generator="OfficeDevPnP.Core, Version=2.22.1801.0, Culture=neutral, PublicKeyToken=null" />
	<pnp:Templates ID="CONTAINER-TEMPLATE">
		<pnp:ProvisioningTemplate ID="TEMPLATE-PROCES" Version="1" BaseSiteTemplate="STS#0" Scope="Web">
			<pnp:Lists>
				<pnp:ListInstance Title="Procedures en templates" TemplateType="101" Url="ProceduresEnTemplates" />
			</pnp:Lists>
		</pnp:ProvisioningTemplate>
	</pnp:Templates>
</pnp:Provisioning>
@waaromikniet

This comment has been minimized.

Copy link
Author

@waaromikniet waaromikniet commented Jul 27, 2018

Your template already worked with the version I tested with. In my template the attribute TemplateFeatureID="00bfea71-e717-4e80-aa17-d0c71b360101" is present. When that attribute is present the url is ignored and the url is the same as the title

@wobba

This comment has been minimized.

Copy link
Contributor

@wobba wobba commented Jul 27, 2018

I added that to my template, still works. Is this an id referencing a list stp you have uploaded?

@waaromikniet

This comment has been minimized.

Copy link
Author

@waaromikniet waaromikniet commented Jul 27, 2018

I created a list in a subweb then saved as a stp. Then I exported my subweb template. Then I try to create a new subweb and apply my template.

I will test with the new version and get back to you. We have the source in our project, Can I use the master branch?

@waaromikniet

This comment has been minimized.

Copy link
Author

@waaromikniet waaromikniet commented Jul 27, 2018

I also see that Id in lists that are exported that weren't created from a stp file. It looks like a default value that is exported. Maybe the default document library template

@wobba

This comment has been minimized.

Copy link
Contributor

@wobba wobba commented Jul 27, 2018

Although stp's are great, and which is what I added support for, it's better to configure it using the template :) But, let me know how it works, if not I'll try to create an stp and reproduce.

@waaromikniet

This comment has been minimized.

Copy link
Author

@waaromikniet waaromikniet commented Jul 27, 2018

I have created a new sitecollection and a new document library for testing. I have no stp file created. When I export this site I also get the TemplateFeatureID="00bfea71-e717-4e80-aa17-d0c71b360101" attribute on all my document library listinstances.

When you look here: https://blogs.technet.microsoft.com/vinitt/2009/11/04/list-of-feature-id-listtemplate/

this ID is of the default document library feature. So for every document library that attribute is added.

@wobba

This comment has been minimized.

Copy link
Contributor

@wobba wobba commented Jul 27, 2018

The export id is an API issue afaik, not a PnP issue, as all stp's get the same id. Had a client report the same, so you need to fix that manually. But that's not the issue for paths ;)

@waaromikniet

This comment has been minimized.

Copy link
Author

@waaromikniet waaromikniet commented Jul 27, 2018

I have tested this with the master version and it still doesn't work. It only works if I remove the TemplateFeatureID attribute. When that is present the url is ignored. Code in ObjectListInstance.cs line 1554
In my test there is no stp file. Out of the box site with a custom list instance. Just the default TemplateFeatureID="00bfea71-e717-4e80-aa17-d0c71b360101"

I have created this site. Exported the template and then try to import with same template on a new site.

@wobba

This comment has been minimized.

Copy link
Contributor

@wobba wobba commented Jul 29, 2018

I'll take a look unless you want to do a PR :)

@wobba

This comment has been minimized.

Copy link
Contributor

@wobba wobba commented Jul 29, 2018

Hmm..looking at the code and from what you are saying, it seems if you set the the ListTemplate the Url parameters is ignored. Need to test this tomorrow then.

@waaromikniet

This comment has been minimized.

Copy link
Author

@waaromikniet waaromikniet commented Sep 10, 2018

@wobba did you find anything on this issue? When I look at the code it indeed seems that when you set ListTemplate the url is ignored during "web.Lists.Add". In ListCreationInformation the URL is present. So could this be going wrong in CSOM instead of PNP.Core?

@wobba

This comment has been minimized.

Copy link
Contributor

@wobba wobba commented Sep 10, 2018

@waaromikniet could you try the latest PnP release which has some changes and see if this resolves it?

@waaromikniet

This comment has been minimized.

Copy link
Author

@waaromikniet waaromikniet commented Sep 10, 2018

@wobba, I have tested it with the master branch but the problem is still there. When
createdList = web.Lists.Add(listCreate);
In CreateList in ObjectListInstance is called I can see that listCreate contains the url "ProceduresEnTemplates" but when the list is created the url is "Procedures%20en%20templates" So properties like: "DefaultEditFormUrl="{site}/ProceduresEnTemplates/Forms/EditForm.aspx" fail because the url of the list is incorrect.

@wobba

This comment has been minimized.

Copy link
Contributor

@wobba wobba commented Oct 5, 2018

@waaromikniet can you propose a code path which will allow this to work, or is it a bug in CSOM when using a specific stp?

@waaromikniet

This comment has been minimized.

Copy link
Author

@waaromikniet waaromikniet commented Oct 5, 2018

I think this is a bug in SharePoint online CSOM. I can't reproduce in onprem. No matter what the stp is. If you export a out of the box SharePoint online site created in the O365 admin center, change the url of a listinstance in the template so it contains no spaces and import again the 'error' occurs. The work around that I use is to delete to attribute TemplateFeatureID. When you want to instantiate a listinstance from a custom stp file you would have a problem if you want the url to be different that the title of the list.

When the attribute TemplateFeatureID is present the url wil always be the same as the title so changing url is not the way to go then

@wobba

This comment has been minimized.

Copy link
Contributor

@wobba wobba commented Oct 5, 2018

@VesaJuvonen notification on this one regarding Url's and stp's.

@migee

This comment has been minimized.

Copy link

@migee migee commented Dec 13, 2018

We appear to be having the same issue on SPO with a production tenant. Oddly, our dev SPO tenant is not impacted. Running 3.1.1809.0. Haven't tried future releases yet as there is currently an issue blocking us in later versions. Only document libraries appear to be impacted for us

@wobba

This comment has been minimized.

Copy link
Contributor

@wobba wobba commented Dec 14, 2018

If you're not using STP's, remove the TemplateFeatureID attribute in your template.

@waaromikniet

This comment has been minimized.

Copy link
Author

@waaromikniet waaromikniet commented Dec 17, 2018

The only way for me to work around this at this moment, is to indeed remove the TemplateFeatureID attribute from the template. In my case only a few. But for larger templates this is still an issue. Also when you export the template the attribute is exported so you can not export and import without fixing your template first. But its not a PNP issue. This should be fixes in the CSOM library

@wobba

This comment has been minimized.

Copy link
Contributor

@wobba wobba commented Dec 17, 2018

@waaromikniet until we get the schema modified to support stp's by name and combine that with the id, removing the featureid is the only way to work around this right now.

cc @PaoloPia

@dharm-4

This comment has been minimized.

Copy link

@dharm-4 dharm-4 commented Mar 15, 2019

@wobba We are also facing same issue. When there is different url & title for list instance and TemplateFeatureID is present then it will causing this problem. after removing TemplateFeatureID attribute it is working fine for custom Url also.

Looking forward for better solution then just remove this attribute at runtime. Let us know if you required more details for same.

@wobba

This comment has been minimized.

Copy link
Contributor

@wobba wobba commented Mar 15, 2019

@dharm-4 It's not hard to solve, but we need to ensure the schema supports it first, ref SharePoint/PnP-Provisioning-Schema#322 cc @PaoloPia

wobba added a commit that referenced this issue Apr 9, 2019
Related to #322
@wobba

This comment has been minimized.

Copy link
Contributor

@wobba wobba commented Apr 9, 2019

When you use schema 2019/03, you can now add an attribute TemplateInternalName to the list instance in the PnP template, which will match the correct feature id and file name to the stp - eg. TemplateInternalName="mylist.stp". Exporting a template will not point to this internal file name and you have to add it yourself - as a list only have reference to the Template FeatureId.

@wobba wobba closed this Apr 9, 2019
@waaromikniet

This comment has been minimized.

Copy link
Author

@waaromikniet waaromikniet commented Apr 10, 2019

Do we still need to manually delete the attribute TemplateFeatureID?

I haven't had time to test this but does this also fixes the url being ignored when the attribute TemplateFeatureID is present? Also it should not ignore the url when a stp is given .

@wobba

This comment has been minimized.

Copy link
Contributor

@wobba wobba commented Apr 10, 2019

@waaromikniet i just added a filter, so you need templatefeatureid, basetype and then add the internalname attribute manually for it to pick the right stp. If you keep templatefeatureid and there is one stp uploaded, that will still be used. Don't want to change this as someone might depend on it. See the 2019-03 schema full sample.

@waaromikniet

This comment has been minimized.

Copy link
Author

@waaromikniet waaromikniet commented Apr 10, 2019

Ok this means I still need to remove the TemplateFeatureID attribute so my url attribute will be applied. Is this something that will stay this way or could this be something that will be solved in future releases?

If TemplateInternalName is missing will it then work as if TemplateFeatureID is missing?

I will try to test this next week,

@wobba

This comment has been minimized.

Copy link
Contributor

@wobba wobba commented Apr 10, 2019

As long as there are no stp's it should possibly work. What is your suggestion to make this as flexible as possible when exporting a template?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.