Some thoughts on programming stuff

Tag: Integration

To export a list you must have a Microsoft SharePoint Foundation-compatible application

SharePoint lists and libraries can be exported to Excel using a out-of-box functionality, but unfortunately SharePoint may present an error message like: To export a list you must have a Microsoft SharePoint Foundation-compatible application.

Putting it in simple words, it’s requiring that you must use Internet Explorer to export the list or you must update your SharePoint site (through a KB or a complete version change) because you are probably using a browser like Chrome or Firefox. . But let’s assume that you don’t have time for that and just want to have the file at that moment? Then we have a quick tip for you! So you finally will get rid of those messages “microsoft sharepoint foundation compatible application” blah blah blah.

The terrible message
Continue reading

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

© 2024 wiliammbr's blog

Theme by Anders NorenUp ↑