Office 365 – SharePoint Online – CSOM – Modern Page Operations for beginners – Disabling the comments on modern page

Hi All,

Today we will discuss how to disable the comments on Modern pages of Modern sites using CSOM. This article is basically targeted for beginners who are looking for Modern sites in Office 365.

Preparation:

I am using Visual Studio 2017 community edition since which is freely available 🙂 . Following are the common steps required to connect to modern site and to access the page. Once preparation is done we will do actual code…

Create the console application as:

fig1_CreatingConsoleApp
Figure 1: Office 365-SharePoint Online – Creating Console Application

Add following keys to app.config file

Installing respective NuGet packages:

Installing “Microsoft.SharePointOnline.CSOM” package for CSOM APIs to connect with our Office 365 site

In Solution Explorer, right click on references and click on option “Manage NuGet Packages” as

fig2_Opening NuGet manager
Figure 2: Office 365 – SharePoint Online – Manage NuGet Packages…

NuGet manager will be opened, under “Browse” tab search for the key “Microsoft.SharePointOnline.CSOM”, and install the searched package as shown in below figure:

fig2_Installing Microsoft.SharePointOnline.CSOM package
Figure 3: Office 365 – SharePoint Online – Installing “Microsoft.SharePointOnline.CSOM” NuGet package

Once we have successfully installed packages, references to following assemblies will be added to our project as shown in below figure:

fig4_References added after installing Microsoft.SharePoint.CSOM NuGet package
Figure 4: Office 365 – SharePoint Online – Assemblies references added after installing “Microsoft.SharePointOnline.CSOM” NuGet package

We will also require installing the package “sharepoint pnp core online” for accessing modern page so in NuGet manager search for the phrase as

fig5_Installing SharePoint PnP Core Online package
Figure 5: Office 365 – SharePoint Online – Installing “SharePoint PnP Core Online” NuGet package

Once we have successfully installed above NuGet package, following assembly  references are added to our package

fig6_References added after installing SharePoint PnP Core Online NuGet package
Figure 6: Office 365 – SharePoint Online – Assemblies references added after installing “SharePoint PnP Core Online” NuGet package

We could also see the progress of installing respective packages in output window.

Once we have respective references in place, we can code 🙂

Code: 

Following is the method to disable the page comments for given page in given site. Added detailed self-explanatory comments to the method.

Test call to the method:

Thanks for reading 🙂

Keep reading, share your thoughts, experiences. Feel free to contact us to discuss more. If you have any suggestion / feedback / doubt, you are most welcome.

Stay tuned on Knowledge-Junction, will come up with more such articles.

Advertisements

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.