Skip to content
Widgets

Sergey Tihon's Blog

On The Roads of Brain Driven Development with F#

Tag: Managed Metadata

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.

Author Sergey TihonCategories SharePointPosted on 19/07/201219/07/2012Leave a comment

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.

Author Sergey TihonCategories SharePointPosted on 22/01/201116/07/2012Leave a comment

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

Author Sergey TihonCategories SharePointPosted on 06/08/201019/07/201213 Comments

Actors Alea.cuBase Algorithms AngularJS Application Insights ASP.NET Async Atlassian Authorization Azure C# Canopy CodePlex Compiler Computer Vision Cpp CUDA Deedle Design Dropbox Editors F# FAKE FAST FsAdvent FSI FsLexYacc Fun Google Graphviz IKVM.NET JavaScript Json.NET Kung Fu Linear algebra LinkedIn Managed Metadata Microsoft Research Monitoring NancyFx NDepend Neo4j News:F# Weekly NoSQL NuGet OAuth Office Online Server OpenGL 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 WCF Web API Web Server WPF XNA

Minsk F# Community

Minsk F# User Group

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

Join 538 other followers

Follow Sergey Tihon's Blog on WordPress.com

Categories

  • Apps (2)
  • Enterprise Search (12)
  • F# (108)
  • F# Weekly (435)
  • Machine Learning (12)
  • NLP (11)
  • SharePoint (19)
  • Tips and Tricks (16)
  • Uncategorized (9)

Archives

  • January 2021 (5)
  • December 2020 (4)
  • November 2020 (4)
  • October 2020 (6)
  • September 2020 (4)
  • August 2020 (5)
  • July 2020 (4)
  • June 2020 (4)
  • May 2020 (5)
  • April 2020 (4)
  • March 2020 (5)
  • February 2020 (5)
  • January 2020 (4)
  • December 2019 (4)
  • November 2019 (6)
  • October 2019 (5)
  • September 2019 (3)
  • August 2019 (5)
  • July 2019 (4)
  • June 2019 (4)
  • May 2019 (5)
  • April 2019 (4)
  • March 2019 (5)
  • February 2019 (4)
  • January 2019 (4)
  • December 2018 (5)
  • November 2018 (4)
  • October 2018 (5)
  • September 2018 (4)
  • August 2018 (4)
  • July 2018 (4)
  • June 2018 (5)
  • May 2018 (4)
  • April 2018 (6)
  • March 2018 (5)
  • February 2018 (4)
  • January 2018 (4)
  • December 2017 (5)
  • November 2017 (2)
  • October 2017 (6)
  • September 2017 (4)
  • August 2017 (5)
  • July 2017 (5)
  • June 2017 (4)
  • May 2017 (4)
  • April 2017 (4)
  • March 2017 (5)
  • February 2017 (5)
  • January 2017 (6)
  • December 2016 (4)
  • November 2016 (4)
  • October 2016 (6)
  • September 2016 (4)
  • August 2016 (6)
  • July 2016 (6)
  • June 2016 (4)
  • May 2016 (6)
  • April 2016 (4)
  • March 2016 (6)
  • February 2016 (3)
  • January 2016 (4)
  • December 2015 (6)
  • November 2015 (6)
  • October 2015 (7)
  • September 2015 (5)
  • August 2015 (5)
  • July 2015 (5)
  • June 2015 (6)
  • May 2015 (4)
  • April 2015 (5)
  • March 2015 (5)
  • February 2015 (5)
  • January 2015 (7)
  • December 2014 (9)
  • November 2014 (6)
  • October 2014 (3)
  • September 2014 (5)
  • August 2014 (4)
  • July 2014 (9)
  • June 2014 (5)
  • May 2014 (4)
  • April 2014 (6)
  • March 2014 (5)
  • February 2014 (4)
  • January 2014 (9)
  • December 2013 (9)
  • November 2013 (8)
  • October 2013 (7)
  • September 2013 (8)
  • August 2013 (6)
  • July 2013 (11)
  • June 2013 (12)
  • May 2013 (8)
  • April 2013 (15)
  • March 2013 (16)
  • February 2013 (11)
  • January 2013 (9)
  • December 2012 (8)
  • November 2012 (12)
  • October 2012 (1)
  • September 2012 (1)
  • August 2012 (1)
  • July 2012 (9)
  • June 2011 (1)
  • January 2011 (2)
  • August 2010 (4)
Sergey Tihon's Blog
Blog at WordPress.com.
Cancel