Question

I am attempting to add a Query String Filter Url Web Part to a page programmatically with JSOM and am hitting a dead end.

I see how you can add a web part if you already have the XML like in this guide: https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/hh185010(v%3Doffice.14)

But how can I get the XML for other OOTB web parts? Thank you so much.

Was it helpful?

Solution

We can go to Web Part Gallery(/_catalogs/wp/Forms/AllItems.aspx), find the web part and click "Edit" and click "View Xml" in the ribbon to get the Xml of the web part.

enter image description here

The xml of the query string web part as following.

<?xml version="1.0" encoding="utf-8"?>
<webParts>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
    <metaData>
      <type name="Microsoft.SharePoint.Portal.WebControls.QueryStringFilterWebPart,Microsoft.Office.Server.FilterControls,Version=15.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
      <importErrorMessage>$Resources:spscore,DwpBdlCannotImport</importErrorMessage>
    </metaData>
    <data>
      <properties>
        <property name="FilterName" type="string">$Resources:spscore,DwpQueryStringFilterName</property>
        <property name="Title" type="string">$Resources:spscore,DwpQueryStringFilterTitle</property>
        <property name="Description" type="string">$Resources:spscore,DwpQueryStringFilterDescription</property>
        <property name="ChromeType">None</property>
        <property name="CatalogIconImageUrl" type="string">/_layouts/images/wp_Filter.gif</property>
        <property name="TitleIconImageUrl" type="string">/_layouts/images/wp_Filter.gif</property>
      </properties>
    </data>
  </webPart>
</webParts>
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top