Hi,
I am developing a Provided hosted app which have a functionality to create a document library with two Views. Also we need to show this document library in a wiki page with two different views.
I am using CSOM (C#). I am able to create the document library and the two views programmatically. But when I add the document library in the wiki page the default view (All Documents) is shown for both the web parts. There is an hidden view created with the WebPartDefinition from the xml provided through code.
Through CSOM we are able make a View as default with the link below.
In my case both the webparts will get the same view, where I need different view for same document library in a wiki page.
Also I tried to update the web parts with the following code.
string viewString = @"<View Name='{0}' MobileView='TRUE' Type='HTML' Url='/SitePages/Home.aspx' Level='1' BaseViewID='1' ContentTypeID='0x' ImageUrl='/_layouts/15/images/dlicon.png?rev=23' ><Query><Where><Eq><FieldRef Name='KeyDocument'/><Value Type='Boolean'>1</Value></Eq></Where></Query><ViewFields><FieldRef Name='FileLeafRef'/><FieldRef Name='DocumentOwner'/><FieldRef Name='Modified'/><FieldRef Name='_UIVersionString'/><FieldRef Name='Editor'/></ViewFields><RowLimit Paged='TRUE'>30</RowLimit><JSLink>clienttemplates.js</JSLink><XslLink Default='TRUE'>main.xsl</XslLink><Toolbar Type='Standard'/></View>"; WebPartDefinition wpd = wpfound.FirstOrDefault(); string formattedstring = String.Format(viewString, wpd.Id); wpd.WebPart.Properties["XmlDefinition"] = formattedstring; wpd.SaveWebPartChanges(); web.Context.ExecuteQuery();I created two views (viewString) as shown above.
The above code did not throw error, but it did not update the web part.
Please advise how to move forward.