Event Receiver to Set Item Level Permissions based on List Column Value

The requirement is to Set Item Level Permission on Document Library Items based on the field in the document library “Visible to Visitors”. The field “Visible to Visitors” is a Checkbox. Technically, When this column set to True, We’ll have to do nothing. When this column set to False, we’ll have to…

Read more

How to Add Web Parts to the Page Programmatically?

Requirement is to add OOTB and Custom web parts to a web part page programmatically via features. I’m sharing the code snippets: To Add Out Of The Box Web Parts: (E.g. Content Query Web Part, Content Editor, Page Viewer Web Part, etc): Add Page Viewer web part: Programmatically add ListView webpart from:…

Read more

How to Create – Update – Delete SharePoint Views Programmatically?

Often in development we may have to deal with SharePoint Views programmatically. Here I’m sharing the code snippets from my recent project to handle views programmatically. Creating a New View Programmatically: Add/Remove fields to an existing View Programmatically: Get the Fields from View Programmatically: Delete Existing View Programmatically: PowerShell Script to Create…

Read more

Customize Top Navigation Programmatically in SharePoint

Requirement: Had to customize the Top navigation with bunch of provided internal/external links as part of a branding project. Solution: Designed a feature to programmatically add links to top navigation bar. when activated, feature will add bunch of links to the top navigation bar. Customize navigation programmatically in SharePoint: In another SharePoint…

Read more

How to Create SharePoint List or Library Programmatically?

At times, We may have to create List or Document Libraries programmatically. These code snippets will help to get it done. Create a Document Library in SharePoint Using .Net Object Model (C#) For all available List template types, Refer: SPListTemplateType Create a SharePoint List using PowerShell:

Read more

Activate-Deactivate Features Programmatically in SharePoint

At times, We may have to activate/deactivate features programmatically. Here is the code snippet: PowerShell way to Activate-Deactivate Features: To activate a feature in PowerShell: Enable-SPFeature -identity <Feature-Folder-Name/GUID> -URL <URL-of-Web-app/Site coll/Site> To deactivate a feature: Disable-SPFeature -identity <Feature-Folder-Name/GUID> -URL <URL-of-Web-app/Site coll/Site>

Read more

Set Sorting, Filter, Group By in SharePoint Views Programmatically

SharePoint List views uses CAML internally to Filter, Sort list items. In a Recent project, we had to programmatically set the Filter and Sort order of default views. How to Get the CAML? Simple! use U2U CAML Query builder, one of my favorite SharePoint tool. C# code to set the View Filter,…

Read more