AWG Blogs

  • Coding without IF statements - Found below linked article that provides tips on how to avoid using IF statements, with one of the benefits being readability. The tips largely are based o...
    1 day ago
  • Microservices - A species would be a combination of roles [DCI?], instead of being characterized as an animal, which would not necessarily be the best description. At a ...
    2 weeks ago
  • CoR compared to Pipe and Filter - Java World implies the pipes-and-filters architectural style described by Parnas Software systems often employ the equivalent of pipes (e.g., email filter...
    7 months ago
  • Getting ADB Working for SPH-M840 - Had a SPH-M840 Galaxy Ring Virgin Mobile 3G Android version 4.1.2, attempting to install apps from Android Studio failed to detect device. Installed SAMSUN...
    1 year ago
  • How to check if I have write permissions to an Oracle table - SELECT CASE WHEN COUNT(*) > 0 THEN 'YES' ELSE 'NO' END AS PERMISSIONS FROM ( SELECT privilege FROM ( select * from dba_tab_privs where (grantee = 'MY_USE...
    1 year ago
  • Flyweight vs Singleton - Implementations seems to be virtually identical, differing only in style, where the flyweight object is created and held by associated objects (containers:...
    2 years ago
  • init-param vs context-param - see http://javahash.com/difference-between-servlet-init-and-context-parameter/ for background. Gist: context-param variables are global and accessible thro...
    2 years ago
  • rbenv vs RVM - RVM is responsible not only for changing Ruby versions, but for installing rubies and managing gemsets, as well. ...Along with rbenv [to manage ruby versi...
    2 years ago

Friday, July 6, 2012

"Specified view is invalid" error when transferring .webpart

I couldn't figure out why SharePoint would produce ASP.NET error when importing a previously exported .webpart. The quick way to resolve it is to remove the ViewFlag element or set it to 0 in the .webpart file. But I found that when I do this the web part does not set ctx values, such as httpvdir. One workaround is to use Server variables rather than CAML variables in the .webpart's ParameterBinding value. I could also open the page in SPD, and make a minor change and save it, which fixes the problem. But I still need to determine what is causing the issue. (BTW, what does ViewFlag, or its absence, have to do with the issue, and what do the ViewFlag values mean anyways? No-one knows apparently).

I finally reproduced the issue in a simple case:
In SourceSiteCol, create a plain doc library and set ContentTypesEnabled to true ("Allow management of content types").
Save as list template. Copy this to DestSiteCol List template gallery.
On DestSiteCol subsite, create a list based on the uploaded list template.
In a web part page on this subsite, add a ListViewWebPart based on the created list. In SPD, convert it to a DataFormWebPart.
Export it as a .webpart. Then import into another web part page on the same site; the error occurs. Disabling Content type management for the created list makes the error go away. So the problem has something to do with Content Types...

At any rate, when transferring lists and their web parts to other sites, can edit the .webpart as follows:
Look for SelectParameters and change the Parameter with ListID to have ListName, and set its DefaultValue to the current display name of the target list (note, if the display name changes, your web part will break, and you'll have to fix the name in the XSLT).
Remove the  Update, Insert, and Delete params see (http://blogs.msdn.com/b/joshuag/archive/2008/11/10/easily-making-the-data-form-web-part-reusable.aspx).
Set TitleUrl property to the URL of the default view
Set the Title property to the intended title of the web part

No comments:

Post a Comment