none
SPList.Views issue when custom views deployed RRS feed

  • Question

  • Hello!

    I'm working with SharePoint Farm solution using VisualStudio 2012. I've deployed list instance with views via Schema.xml. When I deploy only default 2 views that were created by project item template (List Instance) everything is OK. But when I add additional views the Views property of SPList instance returns no values (checked in PowerShell). Also in SharePoint Manager tool the Views property is displayed as  "Cannot complete this action. Please try again." There is a message in ULS:

    System.Runtime.InteropServices.COMException: Cannot complete this action.  Please try again.<nativehr>0x80004005</nativehr><nativestack></nativestack>, StackTrace:   
     at Microsoft.SharePoint.SPViewCollection.EnsureViewSchema(Boolean fullBlownSchema, Boolean bNeedInitallViews)    
     at Microsoft.SharePoint.SPList.get_Views()    
     at Microsoft.SharePoint.SPList.get_DefaultViewUrl()    
     at Microsoft.SharePoint.SPList.get_OnQuickLaunch()    
     at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)    
     at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)    
     at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)    
     at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)    
     at System.ComponentModel.ReflectPropertyDescriptor.GetValue(Object component)    
     at System.Windows.Forms.PropertyGridInternal.GridEntry.GetPropEntries(GridEntry peParent, Object obj, Type objType)    
     at System.Windows.Forms.PropertyGridInternal.GridEntry.CreateChildren(Boolean diffOldChildren)    
     at System.Windows.Forms.PropertyGridInternal.SingleSelectRootGridEntry.CreateChildren()    
     at System.Windows.Forms.PropertyGridInternal.GridEntry.set_InternalExpanded(Boolean value)    
     at System.Windows.Forms.PropertyGridInternal.GridEntry.Create(PropertyGridView view, Object[] rgobjs, IServiceProvider baseProvider, IDesignerHost currentHost, PropertyTab tab, PropertySort initialSortType)    
     at System.Windows.Forms.PropertyGrid.UpdateSelection()    
     at System.Windows.Forms.PropertyGrid.RefreshProperties(Boolean clearCached)    
     at System.Windows.Forms.PropertyGrid.Refresh(Boolean clearCached)    
     at System.Windows.Forms.PropertyGrid.set_SelectedObjects(Object[] value)    
     at Keutmann.SharePointManager.Components.TabPages.GetPropertyPage(String title, Object obj)    
     at Keutmann.SharePointManager.ViewModel.TreeView.SPTreeNode.GetTabPages()    
     at Keutmann.SharePointManager.Forms.MainWindow.ExplorerClick(SPTreeNode treeNode)    
     at System.Windows.Forms.TreeView.WndProc(Message& m)    
     at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)    
     at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)    
     at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)    
     at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)    
     at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)    
     at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)    
     at Keutmann.SharePointManager.Program.Main()

    My list Schema.xml is

    <?xml version="1.0" encoding="utf-8"?>
    <List xmlns:ows="Microsoft SharePoint" Title="IntentionRequests" FolderCreation="FALSE" Direction="$Resources:Direction;" Url="Lists/IntentionRequests" BaseType="0" xmlns="http://schemas.microsoft.com/sharepoint/" EnableContentTypes="TRUE">
      <MetaData>
        <ContentTypes>
          <ContentType ID="0x012000F1B7EAC289334A129FD22F617E23F088" Name="Order" Inherits="TRUE" Version="0">
            <FieldRefs>
              <FieldRef ID="{74645339-9372-4614-ad36-ffe6ce77ee1b}" DisplayName="Project" Required="TRUE" Name="OrderTargetProject" />
              <FieldRef ID="{049fd225-8369-4992-95c2-768ddb654923}" DisplayName="Reason" Required="TRUE" Name="OrderReason" />
              <FieldRef ID="{567b6406-e3f3-45d4-b687-e6a975e39833}" DisplayName="Approval Path" Required="FALSE" Name="OrderApprovalPath" />
              <FieldRef ID="{867eede3-c171-480a-95cd-f8b6a2c22cec}" DisplayName="Category Level 1" Required="TRUE" Name="CategoryLevel1" />
              <FieldRef ID="{3a488751-4d58-4e39-ba67-a026c523fff2}" DisplayName="Category Level 2" Required="TRUE" Name="CategoryLevel2" />
              <FieldRef ID="{7d4457ac-3ff1-4713-b4c1-276262b308d1}" DisplayName="Category Level 3" Required="TRUE" Name="CategoryLevel3" />
              <FieldRef ID="{dc2e0ef7-a82b-4db9-8216-f5c511941da5}" DisplayName="Order Status" Required="FALSE" Name="OrderStatus" Format="Dropdown" />
              <FieldRef ID="{67df98f4-9dec-48ff-a553-29bece9c5bf4}" DisplayName="$Resources:core,Attachments;" Name="Attachments" />
            </FieldRefs>
          </ContentType>
          <ContentType ID="0x010010AA4ABBF2C2405CBD757F401927E491" Name="Intention Request" Inherits="TRUE" Version="0">
            <FieldRefs>
              <FieldRef ID="{2c39af20-29d6-405c-b425-e3618d865139}" Name="Employee" />
              <FieldRef ID="{66f46b0c-796b-4f1c-bca7-17b74983bf57}" Name="Specification" />
              <FieldRef ID="{d0ce8766-419c-4ae6-96b7-46ea705aa628}" Name="Quantity" />
              <FieldRef ID="{450d1a9b-2c12-4bfb-8b67-0295a9dc7f99}" Name="MarketUnitPrice" />
              <FieldRef ID="{a80b6542-c2b7-4e84-8ac5-5ecf5c1bf65f}" Name="Remark" />
              <FieldRef ID="{d89d30fe-0a2f-47a3-b141-39f21ab135e4}" Name="TotalPrice" />
              <FieldRef ID="{128994e3-ceba-4554-a0f1-0126430912f7}" Name="Available" Hidden="TRUE"/>
              <FieldRef ID="{4c548a42-0757-4dc4-8f2f-044e690973fa}" Name="NeedToBuy"/>
              <FieldRef ID="{be92e04b-0556-4db1-8c64-5a813864cba7}" Name="TotalBuy"/>
            </FieldRefs>
            
          </ContentType>
        </ContentTypes>
        <Fields>
          <Field
         ID="{4c548a42-0757-4dc4-8f2f-044e690973fa}"
         Name="NeedToBuy"
         DisplayName="Need To Buy"
         Type="Calculated"
         ResultType="Number"
         Decimals="0"
         ReadOnly="TRUE"
         Group="SRK">
            <Formula>=Quantity-Available</Formula>
            <FieldRefs>
              <FieldRef Name="Quantity" />
              <FieldRef Name="Available" />
            </FieldRefs>
          </Field>
          <Field
           ID="{be92e04b-0556-4db1-8c64-5a813864cba7}"
           Name="TotalBuy"
           DisplayName="Total Buy"
           Type="Calculated"
           LCID="1058"
           ResultType="Currency"
           ReadOnly="TRUE"
           Group="SRK">
            <Formula>=MarketUnitPrice*NeedToBuy</Formula>
            <FieldRefs>
              <FieldRef Name="NeedToBuy" />
              <FieldRef Name="MarketUnitPrice" />
            </FieldRefs>
          </Field>
          <Field Type="Calculated"
             DisplayName="Total Price" LCID="1058" ResultType="Currency"
             ReadOnly="TRUE" ID="{d89d30fe-0a2f-47a3-b141-39f21ab135e4}" Name="TotalPrice" Group="SRK">
            <Formula>=MarketUnitPrice*Quantity</Formula>
            <FieldRefs>
              <FieldRef Name="Quantity" />
              <FieldRef Name="MarketUnitPrice" />
            </FieldRefs>
          </Field>
        </Fields>
        <Views>
          
          <View BaseViewID="0" Type="HTML" MobileView="TRUE" TabularView="FALSE">
            <Toolbar Type="Standard" />
            <XslLink Default="TRUE">main.xsl</XslLink>
            <RowLimit Paged="TRUE">30</RowLimit>
            <ViewFields>
    
              <FieldRef Name="LinkTitleNoMenu"></FieldRef>
            </ViewFields>
            <Query>
              <OrderBy>
    
                <FieldRef Name="Modified" Ascending="FALSE"></FieldRef>
              </OrderBy>
            </Query>
            <ParameterBindings>
              <ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)" />
              <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
              <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_ONET_HOME)" />
            </ParameterBindings>
          </View>
          <View BaseViewID="1" Type="HTML" WebPartZoneID="Main" DisplayName="$Resources:core,objectiv_schema_mwsidcamlidC24;" Hidden="TRUE" DefaultView="FALSE" MobileView="TRUE" SetupPath="pages\viewpage.aspx" ImageUrl="/_layouts/15/images/generic.png?rev=23" Url="AllItems.aspx">
            <Toolbar Type="Standard" />
            <XslLink Default="TRUE">main.xsl</XslLink>
            <JSLink>clienttemplates.js</JSLink>
            <RowLimit Paged="TRUE">30</RowLimit>
            <ViewFields>
    
              <FieldRef Name="LinkTitle"></FieldRef>
            </ViewFields>
            <Query>
              <OrderBy>
    
                <FieldRef Name="ID"></FieldRef>
              </OrderBy>
            </Query>
            <ParameterBindings>
              <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
              <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" />
            </ParameterBindings>
          </View>
          <View BaseViewID="2"  DefaultView="TRUE"  MobileDefaultView="TRUE"  MobileView="TRUE" Type="HTML" DisplayName="My Orders" SetupPath="pages\viewpage.aspx" Url="MyOrders.aspx" ContentTypeID="0x012001" WebPartZoneID="Main" ImageUrl="/_layouts/15/images/generic.png?rev=23">
            <Toolbar Type="None" />
            <XslLink Default="TRUE">main.xsl</XslLink>
            <JSLink>/_layouts/15/SRK.Purchasing/OrdersView.js</JSLink>
            <Query>
              <OrderBy>
                <FieldRef Name="ID" Ascending="FALSE" />
              </OrderBy>
              <Where>
                <Or>
                  <Eq>
                    <FieldRef Name="Author" />
                    <Value Type="Integer">
                      <UserID Type="Integer" />
                    </Value>
                  </Eq>
                  <Eq>
                    <FieldRef Name="Employee" />
                    <Value Type="Integer">
                      <UserID Type="Integer" />
                    </Value>
                  </Eq>
                </Or>
              </Where>
            </Query>
            <ViewFields>
              <FieldRef Name="LinkTitle" />
              <FieldRef Name="OrderTargetProject" />
              <FieldRef Name="OrderStatus" />
            </ViewFields>
            <RowLimit Paged="TRUE">30</RowLimit>
            <Aggregations Value="Off" />
          </View>
    
          <View MobileView="TRUE" DefaultViewForContentType="TRUE" Type="HTML" Scope="Recursive" DisplayName="Intention Requests" WebPartZoneID="Main" SetupPath="pages\viewpage.aspx" Url="IntentionRequests.aspx" BaseViewID="3" ContentTypeID="0x012000F1B7EAC289334A129FD22F617E23F088" ImageUrl="/_layouts/15/images/generic.png?rev=23">
            <Toolbar Type="None" />
            <XslLink Default="TRUE">main.xsl</XslLink>
            <JSLink>/_layouts/15/SRK.Purchasing/IntentionRequestsView.js</JSLink>
            <Query>
              <OrderBy>
                <FieldRef Name="ID" />
              </OrderBy>
            </Query>
            <ViewFields>
              <FieldRef Name="LinkTitle" />
              <FieldRef Name="MarketUnitPrice" />
              <FieldRef Name="Remark" />
              <FieldRef Name="Specification" />
              <FieldRef Name="Quantity" />
            </ViewFields>
            <RowLimit Paged="TRUE">30</RowLimit>
            <Aggregations Value="Off" />
          </View>
    
          <View MobileView="TRUE" Type="HTML" DisplayName="All Orders" BaseViewID="4" SetupPath="pages\viewpage.aspx" WebPartZoneID="Main" Url="AllOrders.aspx" ContentTypeID="0x012001" ImageUrl="/_layouts/15/images/generic.png?rev=23">
            <Toolbar Type="None" />
            <XslLink Default="TRUE">main.xsl</XslLink>
            <JSLink>/_layouts/15/SRK.Purchasing/OrdersView.js</JSLink>
            <Query>
              <OrderBy>
                <FieldRef Name="ID" Ascending="FALSE" />
              </OrderBy>
            </Query>
            <ViewFields>
              <FieldRef Name="LinkTitle" />
              <FieldRef Name="Employee" />
              <FieldRef Name="OrderStatus" />
              <FieldRef Name="OrderTargetProject" />
            </ViewFields>
            <RowLimit Paged="TRUE">30</RowLimit>
            <Aggregations Value="Off" />
          </View>
          <View MobileView="TRUE" Type="GRID" Scope="Recursive" DisplayName="Stock Verification" WebPartZoneID="Main" SetupPath="pages\viewpage.aspx" Url="StockVerification.aspx" BaseViewID="5" ContentTypeID="0x012000F1B7EAC289334A129FD22F617E23F088" ImageUrl="/_layouts/15/images/generic.png?rev=23">
            <Toolbar Type="None" />
            <XslLink Default="TRUE">main.xsl</XslLink>
            <JSLink>/_layouts/15/SRK.Purchasing/IntentionRequestsView.js</JSLink>
            <Query>
              <OrderBy>
                <FieldRef Name="ID" />
              </OrderBy>
            </Query>
            <ViewFields>
              <FieldRef Name="LinkTitle" />
              <FieldRef Name="MarketUnitPrice" />
              <FieldRef Name="Remark" />
              <FieldRef Name="Specification" />
              <FieldRef Name="Quantity" />
              <FieldRef Name="Available" />
            </ViewFields>
            <RowLimit Paged="TRUE">30</RowLimit>
            <Aggregations Value="Off" />
          </View>
        </Views>
        <Forms>
          <Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
          <Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
          <Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
        </Forms>
      </MetaData>
    </List>


    If my suggestion helped you to solve your problem, please don't forget to mark it as Answer

    Wednesday, February 1, 2017 9:09 AM

Answers

  • Hi,

    Please make sure all the content types(Order and Intention Request) with columns exists.

    And try to remove the all Calculated columns and check if it works.

    More information:

    Walkthrough: Create a Site Column, Content Type, and List for SharePoint

    https://msdn.microsoft.com/en-us/library/ee231593(v=vs.120).aspx

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Ivan Bilokon Wednesday, February 8, 2017 5:13 PM
    Tuesday, February 7, 2017 7:46 AM
    Moderator
  • Thanks, the issue was related to Calculated columns. Weird but despite of everything was OK with list forms and items, the incorrect markup of Calculated columns caused the Views issue. The correct deployment markup I borrowed from this article http://www.hekstra.org/how-to-deploy-a-calculated-field/

    If my suggestion helped you to solve your problem, please don't forget to mark it as Answer

    • Marked as answer by Ivan Bilokon Wednesday, February 8, 2017 5:13 PM
    Wednesday, February 8, 2017 5:13 PM

All replies

  • Hi,

    Please make sure all the content types(Order and Intention Request) with columns exists.

    And try to remove the all Calculated columns and check if it works.

    More information:

    Walkthrough: Create a Site Column, Content Type, and List for SharePoint

    https://msdn.microsoft.com/en-us/library/ee231593(v=vs.120).aspx

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Ivan Bilokon Wednesday, February 8, 2017 5:13 PM
    Tuesday, February 7, 2017 7:46 AM
    Moderator
  • Thanks, the issue was related to Calculated columns. Weird but despite of everything was OK with list forms and items, the incorrect markup of Calculated columns caused the Views issue. The correct deployment markup I borrowed from this article http://www.hekstra.org/how-to-deploy-a-calculated-field/

    If my suggestion helped you to solve your problem, please don't forget to mark it as Answer

    • Marked as answer by Ivan Bilokon Wednesday, February 8, 2017 5:13 PM
    Wednesday, February 8, 2017 5:13 PM