2

I'm creating a SharePoint 2013 sandbox solution. On a Community site, OTB you have the Community Discussion list displayed on the home page. The view is based on Subject view. This gives you the graph with replies and likes next to it.

OTB Discussion list

I'm needing to include this list on a custom page. So I have created a standard .aspx page with the markup with a webpart zone on the page. Below is my elements file.

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="MO_DefaultPageTest">
    <File Path="MO_DefaultPageTest\Test123.aspx" Url="Test123.aspx" ReplaceContent="TRUE">
       <!-- Discussion list-->
      <View List="Lists/Community Discussion" ContentTypeID="0x012001" BaseViewID="3" Type="HTML" WebPartOrder="1" WebPartZoneID="wpzTop">
        <![CDATA[
                        <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="AllowConnect" type="bool">True</property>
                                        <property name="Title" type="string">Discussions List</property>
                                        <property name="ChromeType" type="string">TitleOnly</property>
                                        <property name="TitleUrl" type="string"></property>
                                    </properties>
                                </data>
                            </webPart>
                        </webParts>
                    ]]>
      </View>
    </File>
  </Module>
</Elements>

I've worked out BaseViewID by reading the schema.xml file for the OTB Community discussion list. Now if I activate my feature and view my page, my Discussion list works, but it doesn't show the replies and likes graph.

Not working discussion list

As you can see from the above, it's not displaying the same. If I then edit the webpart, and switch the Selected view to "Subject" it then display correctly.

I'm not even sure where to start to look into fixing this.

1

I tried exporting the Web Part, then importing the XML in the elements file. I tried writing JavaScript that creates and adds the Web Part to the page the first time someone landed on the page, nothing seemed to add the Web Part correctly.

In the end, I put the web part on the page, using SharePoint GUI. Once the page and web part looked how I wanted it to look, I created a site template from it and imported the wsp into Visual Studio.

Looking at the elements file for my page in Visual Studio, it shows my list created using the BinarySerializedWebPart.

<View List="Lists/Community Discussion" DisplayName="" Url="" DefaultView="FALSE" BaseViewID="3" Type="HTML" WebPartOrder="0" WebPartZoneID="wpz" ContentTypeID="0x012001" ID="g_af71974f_6bb0_4754_8726_3e2af09bb873" Hidden="TRUE">
                <BinarySerializedWebPart>
                    <GUIDMap>
                        <GUID Id="48d6424f_4920_4ef5_b819_bc902f8f1166" ListUrl="Lists/Community Discussion" />
                    </GUIDMap>
                    <WebPart ID="{1ea4c56a-bad5-41c5-b793-392622eb52e8}" WebPartIdProperty="g_af71974f_6bb0_4754_8726_3e2af09bb873" WebId="00000000-0000-0000-0000-000000000000" List="{$ListId:Lists/Community Discussion;}" Type="1" Flags="45" DisplayName="" Version="5" Url="/sites/Community/SitePages/Community Home.aspx" WebPartOrder="0" WebPartZoneID="wpz" IsIncluded="True" FrameState="0" WPTypeId="{a6524906-3fd2-ee4e-23ee-252d3c6e0dc9}" AllUsers="B6Dt/mYAAAABAAAAAAAAAAIAAAAvc2l0ZXMvQ29tbXVuaXR5L0xpc3RzL0NvbW11bml0eSBEaXNjdXNzaW9uAC9fbGF5b3V0cy8xNS9pbWFnZXMvaXRkaXNjLnBuZz9yZXY9MjMA/wEUKwAdAgICAwIDAQQAAgICEAISAQEAAgQFCFZpZXdHdWlkBSZ7MUVBNEM1NkEtQkFENS00MUM1LUI3OTMtMzkyNjIyRUI1MkU4fQUMQ2xpZW50UmVuZGVyZwEAAAIOAn0FKy9zaXRlcy9Db21tdW5pdHkvTGlzdHMvQ29tbXVuaXR5IERpc2N1c3Npb24CggEFJS9fbGF5b3V0cy8xNS9pbWFnZXMvaXRkaXNjLnBuZz9yZXY9MjMFCVZpZXdGbGFncygpek1pY3Jvc29mdC5TaGFyZVBvaW50LlNQVmlld0ZsYWdzLCBNaWNyb3NvZnQuU2hhcmVQb2ludCwgVmVyc2lvbj0xNS4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj03MWU5YmNlMTExZTk0MjljI0h0bWwsIFRhYnVs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mQpIiAvPjxQYXJhbWV0ZXJCaW5kaW5nIE5hbWU9Ik5vQW5ub3VuY2VtZW50c0hvd1RvIiBMb2NhdGlvbj0iUmVzb3VyY2Uod3NzLG5vaXRlbXNpbnZpZXdfZGlzY2JvYXJkX2hvd3RvMykiIC8+" View="qKkwMQwAAADoAwAAeJydU9FOwzAM/JVpH9D9wDapLRsqKmPqNt5D43VmbRLFDmMSH09KEQWRIpWnSL672Llz5o8IlzVCLWk5/zgLOE42ooHFNEd1vkEqHRFqtUeuYTr7xYodn7QNABlDk56wlql2igOE1IJgkAEk0fIaKOeCuABTX5MQ2o/a8g5GDl0OxLGiC9gsBGe09mM5G9Sm/s5KWwTKtT47E6BstXG1sMjBGYFKUFIozvEMNORMTysEo6oGiZ353hPHnuhf3k01Wb2aGkvkxXRfHFaDwo1rHo6to/2DRkm3mvhfwjaDAshoRaM7t+nGJeOLt3ik9B6aJ7A7VCUM5veD6V11lPm0xvW5xaPfvUTIarjPnwvQgrLb8tn3H3q3az/lkkzkMJJfC0/RM711xVI3jVPIPlFfnM8+Fe9J2F1J" />
                </BinarySerializedWebPart>
            </View>

I placed this exact code within my elements file of my page. After deploying my code, my web part looked and behaved how it should.

To understand the BinarySerializedWebPart further, take a look at the following blog https://pholpar.wordpress.com/tag/binaryserializedwebpart/, it shows you how to decode the content of the binaryserializedwebpart. Not that I did that myself, however it did help me understand the bits of the BinarySerializedWebPart further.

0

My suggestion is that you open the site using SharePoint manager and look the Schema XML for the Webpart in the Specific page Test123.aspx.

I've done something similar using SharePoint Online browser tool and Office 365, and the BaseViewId is fine, but maybe the difference is that you need to specify the JSLink and XslLink.

My point is that by default is not using that JSLink and is not rendering the Replies and Likes part.

<JSLink>sp.ui.discussions.js|sp.ui.communities.js</JSLink>
<XslLink>thread.xsl</XslLink>
  • Unfortunately that didn't work. I put the <property name="JSLink" type="string">sp.ui.discussions.js|sp.ui.communities.js</JSLink> <property name="XslLink" type="string">thread.xsl<"/XslLink> and the webpart didn't appear. I tried to change the | for &#124; still didn't work. Lastly I removed them to try the actual XmlDefinition from a working webpart. Still didn't work. – Cann0nF0dder May 15 '14 at 10:32
0

I know this is a very old topic, but I was having the exact same issue. The simple fix for me was to go into the lists settings > disable ratings > click ok > enable ratings > select "likes" > click ok.

This fixed it for me. Granted the site was migrated from SP2010 to SP2013. But it may help someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.