PnP-PowerShell icon indicating copy to clipboard operation
PnP-PowerShell copied to clipboard

Set-PnPWebPartProperty throwns an exception when updating XsltListViewWebPart with a list from different site

Open shurick81 opened this issue 9 years ago • 1 comments

Reporting an Issue or Missing Feature

Issue

Expected behavior

I expect applied web part property on the page

Actual behavior

I get an error:

PS C:\GitHub\project-folder>     Set-PnPWebPartProperty -Web charitysite -ServerRelativePageUrl $serverRelativePageUr
l -Identity $webpart.Id -Key JSLink -Value "~site/SiteAssets/styles/newsCSR.js";
Set-PnPWebPartProperty : Exception has been thrown by the target of an invocation.
строка:1 знак:5
+     Set-PnPWebPartProperty -Web projectsite -ServerRelativePageUrl $s ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Set-PnPWebPartProperty], ServerException
    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.WebParts.SetWebPartProperty

In the ULS I can see the following: SPRequest.GetListsWithCallback: UserPrincipalName=i:0).w|s-1-5-21-2083956865-2285523250-3521210832-1104, AppPrincipalName= ,bstrUrl=http://lab1sp4.northeurope.cloudapp.azure.com/sites/000004-brandingfreeteamsite/projectsite/_vti_bin/client.svc/ProcessQuery ,foreignWebId=00000000-0000-0000-0000-000000000000 ,bstrListInternalName={DF35289D-870C-4C0D-A84F-E8DE2C24AD76}

Probably, the PnP component is trying to find a list on the current site but it should find it on another web site. The correct web site id is specified in the web part "WebId" property. So the web part is working, it's displaying the list from another web site but when I try to update a property via Set-PnPWebPartProperty command, I get an error.

I also tried to use web part that shows the list from the same web site and this worked perfectly. So the issue appears for only those web parts that show the list from foreign sites.

Steps to reproduce behavior

Please include complete code samples in-line or linked from gists

the list is on /sites/brandingfreeteamsite/news the page is on /sites/brandingfreeteamsite/projectsite

First, I use PnP Provisioning engine to add the web part that shows the list from another site. Here is the example of the model:

                        <pnp:WebPart Zone="Body" Order="0" Title="Relevant News">
                            <pnp:Contents>
                                <webParts>
                                    <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
                                        <metaData>
                                            <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
                                            <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
                                        </metaData>
                                        <data>
                                            <properties>
                                                <property name="Title" type="string">Relevant News</property>
                                                <property name="ListDisplayName" type="string">News</property>
                                                <property name="WebId" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">7344198f-c261-43b0-af69-e60fd2a2ee65</property>
                                                <property name="ListName" type="string">{df35289d-870c-4c0d-a84f-e8de2c24ad76}</property>
                                            </properties>
                                        </data>
                                    </webPart>
                                </webParts>
                            </pnp:Contents>
                        </pnp:WebPart>

Then I try to apply the following command: Set-PnPWebPartProperty -Web $webUrl -ServerRelativePageUrl $serverRelativePageUrl -Identity $webpart.Id -Key JSLink -Value "~site/SiteAssets/styles/newsCSR.js";

Which version of the PnP-PowerShell Cmdlets are you using?

  • [X] PnP PowerShell for SharePoint 2013
  • [ ] PnP PowerShell for SharePoint 2016
  • [ ] PnP PowerShell for SharePoint Online

What is the version of the Cmdlet module you are running?

(you can retrieve this by executing Get-Module -Name *pnppowershell* -ListAvailable)

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     2.16.17... SharePointPnPPowerShell2013         {Add-PnPContentType, Add-PnPContentTypeToDocumentSet, Add-...

How did you install the PnP-PowerShell Cmdlets?

  • [ ] MSI Installed downloaded from GitHub
  • [X] Installed through the PowerShell Gallery with Install-Module
  • [ ] Other means

shurick81 avatar Aug 16 '17 09:08 shurick81

We closed this issue as it had not activity within last 180 days. This is a generic process we have decided to perform for issues, which have not been explicitly marked still to be "work in progress" based on tags. We are performing this cleaning to make sure that old issues that have already been solved (but not closed) or are no longer relevant are cleaned out and make the issues more manageable. If this issue still valid, we would ask you to open a new issue and follow the guidance in the issue template related on the recommended location. We do apologize any inconveniences this might cause. Please do remember that issues in the issue lists are also messages for others in the community, so you can also check if you can assist on any of them. “Sharing is caring!”

spdevdocs avatar Apr 28 '18 14:04 spdevdocs