SOLVED

Specify view for XsltListViewWebPart using PnP Provisioning Engine

%3CLINGO-SUB%20id%3D%22lingo-sub-33812%22%20slang%3D%22en-US%22%3ESpecify%20view%20for%20XsltListViewWebPart%20using%20PnP%20Provisioning%20Engine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33812%22%20slang%3D%22en-US%22%3E%3CP%3EI%20wonder%20if%20it%20is%20possible%20to%20specify%20what%20list%20view%20should%20be%20used%20when%20adding%20an%20XsltLitViewWebPart%20to%20a%20page%20with%20the%20PnP%20Provisioning%20Engine%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-33812%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-37808%22%20slang%3D%22en-US%22%3ERe%3A%20Specify%20view%20for%20XsltListViewWebPart%20using%20PnP%20Provisioning%20Engine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-37808%22%20slang%3D%22en-US%22%3E%3CP%3EAwesome%2C%20and%26nbsp%3Bfeel%20free%20to%20change%20my%20answer%20to%20%22best%20response%22%20%3B)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-37806%22%20slang%3D%22en-US%22%3ERe%3A%20Specify%20view%20for%20XsltListViewWebPart%20using%20PnP%20Provisioning%20Engine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-37806%22%20slang%3D%22en-US%22%3E%3CP%3EAwesome!%20That%20really%20worked%2C%20thanks%20for%20putting%20light%20on%20this.%20Wasn't%20able%20to%20see%20that%20when%20going%20through%20the%20PnP%20source%20code!%20Have%20now%20replaced%20my%20custom%20extention%20handler%20with%20this!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-37612%22%20slang%3D%22en-US%22%3ERe%3A%20Specify%20view%20for%20XsltListViewWebPart%20using%20PnP%20Provisioning%20Engine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-37612%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EIt's%20directly%20supported%20in%20PnP%20via%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-Sites-Core%2Fissues%2F584%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FSharePoint%2FPnP-Sites-Core%2Fissues%2F584%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20your%20webpart%20xml%20add%20one%20of%20the%20following%20params%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3EViewId%20(guid%20of%20view)%3C%2FLI%3E%3CLI%3EViewGuid%26nbsp%3B%3CSPAN%3E(guid%20of%20view)%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3EViewName%20(display%20name%20of%20view)%3C%2FLI%3E%3CLI%3EViewUrl%20(server%20relative%20url%20of%20view)%26nbsp%3B%3C%2FLI%3E%3C%2FUL%3E%3CP%3EIn%20my%20case%20I%20have%20a%20list%20view%20named%20%22Recently%20modified%20documents%22%2C%20and%20added%20this%20to%20the%20webpart%20properties%20xml%20in%20my%20provisining%20template.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CPROPERTY%20name%3D%22%26quot%3BViewName%26quot%3B%22%20type%3D%22%26quot%3Bstring%26quot%3B%22%3ERecently%20modified%20documents%3C%2FPROPERTY%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPnP%20then%20fixes%20the%20hidden%20view%20automatically%20for%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-33940%22%20slang%3D%22en-US%22%3ERE%3A%20Specify%20view%20for%20XsltListViewWebPart%20using%20PnP%20Provisioning%20Engine%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33940%22%20slang%3D%22en-US%22%3EYes%20it%20is%20using%20a%20extensibility%20provider%20in%20your%20template%20see%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.com%2Fpaul-keijzers%2F4594%2Funable-to-change-view-of-list-view-web-part-csom%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.com%2Fpaul-keijzers%2F4594%2Funable-to-change-view-of-list-view-web-part-csom%3C%2FA%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

I wonder if it is possible to specify what list view should be used when adding an XsltLitViewWebPart to a page with the PnP Provisioning Engine?

4 Replies
Highlighted
Best Response confirmed by Johannes Ekstrand (New Contributor)
Highlighted

Hi,

It's directly supported in PnP via https://github.com/SharePoint/PnP-Sites-Core/issues/584

 

In your webpart xml add one of the following params:

 

  • ViewId (guid of view)
  • ViewGuid (guid of view)
  • ViewName (display name of view)
  • ViewUrl (server relative url of view) 

In my case I have a list view named "Recently modified documents", and added this to the webpart properties xml in my provisining template.

 

<property name="ViewName" type="string">Recently modified documents</property>

 

PnP then fixes the hidden view automatically for you.

Highlighted

Awesome! That really worked, thanks for putting light on this. Wasn't able to see that when going through the PnP source code! Have now replaced my custom extention handler with this!

Highlighted

Awesome, and feel free to change my answer to "best response" ;)