LoginSignup
1
1

More than 5 years have passed since last update.

SharePoint CSOM で「最近使った項目」の中のアイテムを消し去る

Posted at

SharePoint アプリ、じゃなかった SharePoint アドインを追加すると、勝手にサイドメニューに追加されるので消したかったのです。今回は C#です。

// サイドナビゲーション取得
NavigationNodeCollection navLocalNodes = clientContext.Web.Navigation.QuickLaunch;

// 最近使った項目から消し去るために探す
IEnumerable<NavigationNode> ndRecent
    = clientContext.LoadQuery(
        navLocalNodes.Include(
            n => n.Id,
            n => n.Children.Include(
                n2 => n2.Url, n2 => n2.Title
            ).Where( n2 => n2.Title == "(消し去りたい見出し)" )
        ).Where( n => n.Id == 1033 ) // 最近使った項目のIDを指定
    );
// いったんサーバーからお取り寄せ
clientContext.ExecuteQuery();

// グルグルと
ndRecent.ToList().ForEach( n =>
{
    n.Children.ToList().ForEach( n2 =>
    {
        // 最近使った項目から消し去る
        n2.DeleteObject();
        n2.Update();
    });
});
// さようなら
clientContext.ExecuteQuery();

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1