0

I'm trying to add a listview webpart to my default page of my sandboxed solution for SharePoint 2013 in Office 365.

I'm using a ONET file to define my webtemplate based on the STS template. Among other features I've activated the publishing feature. In there I use a web feature with a elements file that provisions the default page.

Everyting is working well, I can even add a listview webpart to this page which shows the content of the default documents list.

However, it seems that with every other list (Tasks, Calendar,..) I try to show in a View element in my default page, prevents me from creating the site.

I tried several approaches:

Physically adding the calendar list to lists (Change list path in ONET file):

<View List="Lists/Calendar" 
        Name="Calendar"
        BaseViewID="0" 
        WebPartZoneID="TopLeftRow" 
        WebPartOrder="0"/>

Adding the calendar list without lists:

<View List="Calendar" 
        Name="Calendar"
        BaseViewID="0" 
        WebPartZoneID="TopLeftRow" 
        WebPartOrder="0"/>

With resource file:

<View List="$Resources:core,calendarList;" 
       BaseViewID="0" 
       WebPartZoneID="TopLeftRow" 
       WebPartOrder="0" />

With body xml:

<View List="Lists/Calendar" BaseViewID="0" WebPartZoneID="TopLeftRow" WebPartOrder="1">
    <![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="Title" type="string">Calendar</property>
                      <property name="DisableViewSelectorMenu" type="bool">True</property>
                      <property name="InplaceSearchEnabled" type="bool">False</property>
                      <property name="ShowToolbarWithRibbon" type="bool">False</property>
                      <property name="ChromeType" type="chrometype">TitleOnly</property>
                  </properties>
              </data>
          </webPart>
      </webParts>]]>
  </View>

None of these approaches seem to work. Am I doing something wrong here?

Update It seems to be a timing issue. When I disable the feature that provisions the default page and enable it by hand it works using this:

<View BaseViewID="2" List="$Resources:core,lists_Folder;/$Resources:core,calendar_Folder;" WebPartZoneID="TopRightRow" DefaultView="TRUE" Type="CALENDAR" WebPartOrder="1" >
    <![CDATA[ 
      <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2"> 
      <Assembly>Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>          
      <TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName> 
      <Title>Calendar</Title>                          
      </WebPart>]]>
  </View>

Any Idea how I can fix this, regarding the use of a webtemplate in a sandbox solution?

1

First create the list you are trying to reference in the feature receiver that you added to your onet.xml file. Then create the list view web part as you have done in your onet.xml.

This will result in your list being there when you are trying to reference it by creating the list view web part.

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.