Skip to content
  • Home
  • Blog
  • F# Weekly
  • F# Advent
  • F# Events
  • Mastodon
  • Github
  • LinkedIn
  • StackOverflow
  • NuGet
  • Goodreads
  • Twitter

Sergey Tihon's Blog

Going its own way with F#

Tag: Managed Metadata

Navigation hierarchies and key filters with slide library : Code Fix.

19/07/201219/07/2012Categories SharePointLeave a Comment on Navigation hierarchies and key filters with slide library : Code Fix.

According to the popularity of the blog post : “Navigation hierarchies and key filters with slide library“, I decided to share a code that fix Slide Library view. This code snippet replace existing ListViewWebPart on the slide library view to the new XsltListViewWebPart and configure it in a proper way.

If you execute this code on the all slide library views then you will get a full-functional slide library with fixed navigation and filters.

public bool ReplaceListViewWebPartForView(SPWeb web, SPList list, SPView view)
{
  using (SPLimitedWebPartManager webPartManager =
               web.GetLimitedWebPartManager(view.Url, PersonalizationScope.Shared))
  {
    SPLimitedWebPartCollection pageWebParts = webPartManager.WebParts;

    ListViewWebPart listViewWebPart =
                       pageWebParts.OfType<ListViewWebPart>().FirstOrDefault();
    if (listViewWebPart == null || listViewWebPart.IsClosed) return false;

    var xsltListViewWebPart =
      new XsltListViewWebPart
      {
        ListName = listViewWebPart.ListName,
        ViewFlags = listViewWebPart.ViewFlags,
        ViewId = listViewWebPart.ViewId,
        ViewGuid = listViewWebPart.ViewGuid,
        Visible = listViewWebPart.Visible,
        DisplayName = view.Title,
        Default = view.DefaultView.ToString().ToUpper(),
        WebId = listViewWebPart.WebId,
        NoDefaultStyle = listViewWebPart.UseDefaultStyles.ToString().ToUpper()
      };

    //create new Webpart and set parameters from existing ListViewWebPart
    webPartManager.AddWebPart(xsltListViewWebPart, listViewWebPart.ZoneID, 0);

    //fix ViewFlags since SP added "Hidden" flag
    xsltListViewWebPart.ViewFlags = listViewWebPart.ViewFlags;
    webPartManager.DeleteWebPart(listViewWebPart);
    webPartManager.SaveChanges(xsltListViewWebPart);

    list.Update();
    web.Update();

    //get updated list and fix issue with empty title to allow View be visible on the site
    SPList list1 = web.Lists[list.ID];
    SPView view1 = list1.Views[new Guid(xsltListViewWebPart.ViewGuid)];
    view1.Title = view.Title;
    view1.DefaultView = view.DefaultView;
    view1.MobileDefaultView = view.MobileDefaultView;
    view1.MobileView = view.MobileView;
    view1.Update();

    web.Update();
    return true;
  }
}

P.S. Great thanks to the Dmitry Chirun for this fix.

How to migrate “Managed Metadata Service”

22/01/201116/07/2012Categories SharePointLeave a Comment on How to migrate “Managed Metadata Service”

This is task appeared when I needed to migrate SharePoint site collection from one farm to another.

First time we had used SharePoint 2010 back up mechanism, but this approach hard enough. We had a lot of errors during restore: broken connector, errors with content hub, access problems and so on. Every such restoration has brought new errors. We could not document restore process well enough.But then we have found new way of migration.

Migration guide simple and short:

  1. Open SQL Server Management Studio and create back of Managed Metadata Service’s database (every Managed Metadata Service has their own database. Database name is something like this “Managed Metadata Service_0eb8ebdccb234c5ea23e677d816e845f”)
  2. Restore database from this backup into new farm to database of another Managed Metadata Service.

 

Keep in the mind, that you can not create two Managed Metadata Services in the one farm this way, because  the Guid of the service store directly in the database. After such restore you can work with just one service.

Navigation Hierarchies and Key Filters with Slides Library

06/08/201019/07/2012Categories SharePoint13 Comments on Navigation Hierarchies and Key Filters with Slides Library

Update : Added a new blog post with a code fix of this issue – “Navigation hierarchies and key filters with slide library : Code Fix“

Some month ago I encountered with a problem of using Navigation Hierarchies and Key Filters with Slides Library. I was added the Managed Matadata field to my slides library and turned on the  Navigation Hierarchies and Key Filters on the Library Settings page and nothing happened. But the same sequence of actions works with Document Library.

In SharePoint’s logs I had found following record:

MetadataNavigationContext Page_InitComplete: No XsltListViewWebPart was found on this page[…].  Hiding key filters and downgrading tree functionality to legacy ListViewWebPart(v3) level for this list.    265d58e5-27f4-40a3-8ab5-4b80013588ab

I have placed my problem to MSDN SharePoint 2010 Forum : http://social.msdn.microsoft.com/Forums/en/sharepoint2010general/thread/a7970e71-6895-4751-a2be-d9043c9ddd6c but it did not help me =)

We have found the solution of this problem and I will try share it to you.

Let’s open default view page of the slide library in the SharePoint Designed 2010.

And what we see? Default view page which was generated by default slide library template contains old ListViewWebPart. We need to replace this web part on the new XsltListViewWebPart .

I propose you the way to do it without using any custom utils except SharePoint web UI.

  1. Open the Slide Library and click Site Actions\Edit Page.
  2. Choose a web part and click Edit Web Part.
  3. Change the Selected View property from <Current view> to <Summary view>. And click OK but  do not click Apply.
  4. Click OK in the  popup window.
  5. Click the name of your library into the left navigation panel.

Now you can open the view in the SharePoint Designer 2010 and see that web part was changed.

Navigation Hierarchies and Key Filters also working.

P.S. Thank to Aliaksandr Haurylik


Going its own way with F#. Open source enthusiast. Microsoft F# MVP. Husband. Employed by EPAM Systems. Tweets are my own.

Categories

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 617 other subscribers

Tags

Actors Alea.cuBase Algorithms AngularJS ASP.NET Async Atlassian Authorization Azure C# Canopy CodePlex Compiler Cpp CUDA Deedle Design Dropbox Editors F# FAKE FAST Fea Featured FsAdvent FSI FsLexYacc Fun Google Graphviz IKVM.NET JavaScript Json.NET Kung Fu Linear algebra LinkedIn Managed Metadata Microsoft Research NancyFx NDepend Neo4j News:F# Weekly NoSQL NuGet OAuth OpenGL OpenXML OWIN PowerShell REST RProvider Scala Search ServiceStack SharePoint 2010 SharePoint 2013 Silverlight 4 Slides Library Solr Stanford NLP Storm Swagger Swashbuckle Talks Twitter Type Providers TypeScript Vagrant Visual Studio vscode WCF Web API Web Server WPF XNA
Follow Sergey Tihon's Blog on WordPress.com
  • Mastodon
  • Github
  • LinkedIn
  • StackOverflow
  • NuGet
  • Goodreads
  • Twitter
Create a website or blog at WordPress.com
  • Home
  • Blog
  • F# Weekly
  • F# Advent
  • F# Events
  • Follow Following
    • Sergey Tihon's Blog
    • Join 602 other followers
    • Already have a WordPress.com account? Log in now.
    • Sergey Tihon's Blog
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...