Some thoughts on programming stuff

Month: March 2017

List operations with CSOM and C# in SharePoint

Sometimes we have to query a SharePoint list through remote connections using C#. It can happen in a SharePoint App, a Console Application or maybe on an Azure Function. This post will help on performing list operations with CSOM and C# in SharePoint.

Below you can find some code snippets that will help you on integrating SharePoint lists with your application.

Basically, you will have to add the Microsoft.SharePoint.Client namespace.

using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;

The required DLLs for programming these type of solution are:

Microsoft.SharePoint.Client.dll
Microsoft.SharePoint.Client.Runtime.dll

You can find them inside those folders:

SharePoint 2010: 14 Hive -> Folder: ISAPI

SharePoint 2013: 15 Hive -> Folder: ISAPI

Or just download it from MSDN, inside the SharePoint Server 2013 Client Components SDK!

After adding these references to our project, we can start coding and accessing the data in the SharePoint List you want!

A custom list creation screen

Soon you will notice that everything depends on the ClientContext object, which manages the requests and the data that will be loaded.

In our examples we are going to use the variable siteUrl, that represents the URL for the Site Collection. The variable listTitle will also be used and it represents the Title of the list being used.

string siteUrl = "http://sitesharepoint";
string listTitle = "SharePointList";

So, let’s do some real stuff here:

Read operation in SharePoint lists

Filtering and selecting specific fields

The example below presents a simple code that queries only one list item from the List and specifies some specific columns to be returned. It’s important to say that exists lots of best practices to build good queries in SharePoint.

Creation operation in SharePoint lists

 Update operation in SharePoint lists

 Delete operation in SharePoint lists

I believe these are the basics for consuming SharePoint lists. In the future I’m planning to show some complex examples, more focused on Office 365 and Azure integrations. Thanks for reading and I hope it can be useful to you when you need to perform list operations with CSOM and C# in SharePoint.

References:
MSDN

Study Guide for Exam 70-488 – Developing Microsoft SharePoint Server 2013 Core Solutions

Since last year, we received the announcement that some of the SharePoint 2013 certifications were being retired in September of last year. But after that, they extended the deadline to 2017. This new deadline can be explained due there is no new certifications focused on development for SharePoint 2016 have been released yet.

Exam on Microsoft’s website: https://www.microsoft.com/pt-br/learning/exam-70-488.aspx

Therefore, here is a set of links that you can use as a study guide to pass on that exam before it is retired.
This summary was once made by Martin Bodocky and kept on this blog post “70-488 – Developing Microsoft Sharepoint Server 2013 Core Solutions – Preparation links“. Unfortunatelly, it’s not online anymore, so I decided to provide this information once again at the same time that I must say: Bodocky made everything and helped me on passing this exam, back on 2014.

If you want to read the preparation links for the Advanced Solutions, please check the post for the test Study Guide for Exam 70-489 – Developing Microsoft SharePoint Server 2013 Advanced Solutions.

Continue reading

© 2024 wiliammbr's blog

Theme by Anders NorenUp ↑