Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

ApplyProvisioningTemplate creates duplicate views #2540

Open
karinebosch opened this issue Feb 10, 2020 · 8 comments
Open

ApplyProvisioningTemplate creates duplicate views #2540

karinebosch opened this issue Feb 10, 2020 · 8 comments

Comments

@karinebosch
Copy link

We use ApplyProvisioningTemplate to provision new SharePoint sites. The template XML contains XML like this (generated by the method GetProvisioningTemplate):














30
clienttemplates.js

etc.

We expect the default view to get the custom fields, but instead a duplicate view is created:

  • the standard view "AllItems.aspx" is not modified (and remains)
  • a second view "AllItems1.aspx" is created, with the correct fields added to it, and becomes the default view
  • Navigation links in the left menu continue to link to AllItems.aspx

Tenant and SharePoint sites have "Dutch" regional settings.

Which PnP repository should you use to report the issue?

Category

[ ] Bug

Environment

[ ] Office 365 / SharePoint Online

Duplicate views
CustomProjectTemplate_TEST.txt

@ghost
Copy link

ghost commented Feb 10, 2020

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 label Feb 10, 2020
@erwinvanhunen
Copy link
Member

Hi Karine,

Does it occur for all list instances in your template or a specific one?

@erwinvanhunen
Copy link
Member

erwinvanhunen commented Feb 10, 2020

I cleaned up your template, and limited it to one list, Correspondenties, which seemed to one you reference in your screenshot? It works as expected for me. The logic behind the scenes that we use (and there is unfortunately no way around that) is that we use the -title/displayname- of the view to determine if the view is present. If present we will delete that view and recreate it. What is the default title of the existing view? Is there something going on by the site being created in a different language and as such the title of the view is different from what is being presented to the user?

@karinebosch
Copy link
Author

karinebosch commented Feb 10, 2020

Hi Erwin, are you sure that in your code you don't check on "All documents" for example? Because the standard view in our template site is "Alle documenten", just as in the template XML. When the new site is created, the default view is also "Alle documenten".
The standard view "Alle documenten" is created on AllItems.aspx, and the second one is created on AllItems1.aspx.
But it is weird that you don't have the same issue when you execute my template.

@erwinvanhunen
Copy link
Member

this is the check we do:

var viewTitle = parser.ParseString(displayNameElement.Value);
var existingView = existingViews.FirstOrDefault(v => v.Title == viewTitle);
if (existingView != null)
{
    existingView.DeleteObject();
    web.Context.ExecuteQueryRetry();
}

parseString is our internal code that replaces tokens in strings for the actual values.

We also have a 'RemoveExistingViews' attribute on the pnp:Views element that you didn't set. Can you try that one?

 <pnp:Views RemoveExistingViews="true">
            <View DisplayName="View One">
              <ViewFields>
                <FieldRef Name="ID" />
     etc. etc.

@erwinvanhunen
Copy link
Member

regarding the language: is the site created as as Dutch site? Or is it created as an English site and has Dutch enabled? If you use PnP PowerShell and do Get-PnPView -List 'yourlistname' Do you also get 'Alle documenten' back?

@karinebosch
Copy link
Author

Hi Erwin,
Executing the Get-PnPView cmdlet gives me all views, also containing 2 times "Alle documenten":
Alle documenten d74ccb88-ec79-4507-a7e1-a565e2fa1f09 False False
Documenten samenvoegen 4c62059b-56cc-4a77-b3f3-9bad57bf8e61 False False
Documenten opnieuw koppelen 42143ef3-9010-41d9-8427-0bc3ed573268 False False
assetLibTemp eda8e5c9-2d95-401e-8429-c85919739dac False False
Alle documenten d1ad2cc7-ef7d-4856-aea0-215828e8badc True False
Interne Correspondenties f79ce364-28d4-494a-8a18-e851cd44bfbc False False
Klant Correspondenties ed16ee40-9ce2-4cd5-a576-d559cee31ed6 False False
Leverancier Correspondenties e544e8ab-a313-423b-846b-86feda18c2f5 False False
Andere Correspondenties 291df196-2a1c-4049-872b-741c028041df False False

Tomorrow, I'll try to use the RemoveExistingViews attribute, and I'll let you know.
Thanks for your help!
Karine

@karinebosch
Copy link
Author

Hi Erwin,
The RemoveExistingViews attribute as solved our issue!
Thanks for your help!
Karine

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants