Basic Operation’s That SharePointer Needs For SharePointing By Using CSOM – Part 3

Previously in part one we discussed the main operation that developers needs to deal with SharePoint site , and in part 2 , we talked about  SharePoint list , and the bellow examples show how to use the .NET Framework CSOM to complete list item -related tasks.

SharePoint list item tasks

These examples demonstrate how to use the .NET Framework CSOM (Client side object model) to complete tasks that are related to list items.

Retrieve items from a SharePoint list

This example retrieves the items in a SharePoint list. You also need to add a using statement for Microsoft.SharePoint.Client.QueryExpression.

Note

You can use the FolderServerRelativeUrl property to further restrict the items that are returned to those in a specified folder.

C#
// Starting with ClientContext, the constructor requires a URL to the 
// server running SharePoint. 
ClientContext context = new ClientContext("http://developersportal.net"); 

// Assume the web has a list named "Announcements". 
List announcementsList = context.Web.Lists.GetByTitle("Announcements"); 

// This creates a CamlQuery that has a RowLimit of 100, and also specifies Scope="RecursiveAll" 
// so that it grabs all list items, regardless of the folder they are in. 
CamlQuery query = CamlQuery.CreateAllItemsQuery(100); 
ListItemCollection items = announcementsList.GetItems(query); 

// Retrieve all items in the ListItemCollection from List.GetItems(Query). 
context.Load(items); 
context.ExecuteQuery(); 
foreach (ListItem listItem in items) 
{ 
    // We have all the list item data. For example, Title. 
    label1.Text = label1.Text + ", " + listItem["Title"]; 
} 

Create a new list item

This example creates a new SharePoint list item by using the ListItemCreationInformation class.

C#
// Starting with ClientContext, the constructor requires a URL to the 
// server running SharePoint. 
ClientContext context = new ClientContext("http://developersportal.net"); 

// Assume that the web has a list named "Announcements". 
List announcementsList = context.Web.Lists.GetByTitle("Announcements"); 

// We are just creating a regular list item, so we don't need to 
// set any properties. If we wanted to create a new folder, for 
// example, we would have to set properties such as 
// UnderlyingObjectType to FileSystemObjectType.Folder. 
ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation(); 
ListItem newItem = announcementsList.AddItem(itemCreateInfo); 
newItem["Title"] = "New Item!"; 
newItem["Body"] = "Hello Developers world!"; 
newItem.Update(); 

context.ExecuteQuery();  

Update a list item

This example updates a SharePoint list item.

C#
// Starting with ClientContext, the constructor requires a URL to the 
// server running SharePoint. 
ClientContext context = new ClientContext("http://developersportal.net"); 

// Assume that the web has a list named "Announcements". 
List announcementsList = context.Web.Lists.GetByTitle("Announcements"); 

// Assume there is a list item with ID=1. 
ListItem listItem = announcementsList.GetItemById(1); 

// Write a new value to the Body field of the Announcement item.
listItem["Body"] = "This is my new value!!"; 
listItem.Update(); 

context.ExecuteQuery();  

Delete a list item

This example deletes a SharePoint list item.

C#
// Starting with ClientContext, the constructor requires a URL to the 
// server running SharePoint. 
ClientContext context = new ClientContext("http://developersportal.net"); 

// Assume that the web has a list named "Announcements". 
List announcementsList = context.Web.Lists.GetByTitle("Announcements"); 

// Assume that there is a list item with ID=2. 
ListItem listItem = announcementsList.GetItemById(2); 
listItem.DeleteObject(); 

context.ExecuteQuery(); } 
Please follow and like us:

basic operation’s that SharePointer needs for SharePointing by using CSOM – part 1

Yes, SharePoint is awesome and I really enjoyed with developing apps on it, and in this article I’ll list down the basic operation that SharePoint developer needs while SharePointing  by using CSOM

We have four main things to deal with in SharePoint

  • Operations on SharePoint site  – Part 1
  • Operations on SharePoint List- Part 2
  • Operations on SharePoint List item -Part 3
  • Operations on SharePoint Users- Part 4

And I’ll start with SharePoint site operation

Ø  Get all Website properties

Retrieve the title of a SharePoint website.

C#

// Starting with ClientContext, the constructor requires a URL to the
// server running SharePoint. 
ClientContext context = new ClientContext("http://Developersportal.net"); 
// The SharePoint web at the URL.
Web web = context.Web;  
// We want to retrieve the web's properties.
context.Load(web);
// Execute the query to the server.
context.ExecuteQuery(); 
// Now, the web's properties are available and we could display
// web properties, such as title. 
label1.Text = web.Title;

 

However you can retrieve only selected properties of a website

If you are  interested only in a few properties of the Site object. The SharePoint  Framework CSOM (Client side object model)  does not require you to get all properties from the object on a serve, so  you can use lambda expressions, to specifically requested property names.

By using this technique you’ll reduce the unnecessary data transfer between the client and the server..

Note that you need to add a using statement for System.Linq.

C#

// Starting with ClientContext, the constructor requires a URL to the 
// server running SharePoint. 
ClientContext context = new ClientContext("http://developersportal.net");  
// The SharePoint web at the URL.
Web web = context.Web;  
// We want to retrieve the web's title and description. 
context.Load(web, w => w.Title, w => w.Description);  
// Execute the query to server.
context.ExecuteQuery();  
// Now, only the web's title and description are available. If you 
// try to print out other properties, the code will throw 
// an exception because other properties are not available. 
label1.Text = web.Title;
label1.Text = web. Description;

 

Ø  Update SharePoint site’s properties

This example shows how to write to the website’s properties.

C#

// Starting with ClientContext, the constructor requires a URL to the 
// server running SharePoint. 
ClientContext context = new ClientContext("http://developersportal.net");  
// The SharePoint web at the URL.
Web web = context.Web;  
web.Title = "New Title (Devalopers Portal Awesome Team)";
web.Description = "New Description";  
// Note that the web.Update() does not trigger a request to the server
// because the client library until ExecuteQuery() is called. 
web.Update();  
// Execute the query to server.
context.ExecuteQuery();

 

Ø  Create a new SharePoint site

This example shows how to create a new SharePoint site as a subsite of the current website. Use the WebCreationInformation class to create a new website. You also need to add using statements for System.Collections.Generic and System.Text.

C#

// Starting with ClientContext, the constructor requires a URL to the 
// server running SharePoint. 
ClientContext context = new ClientContext("http://developersportal.net ");  
WebCreationInformation creation = new WebCreationInformation();
creation.Url = "sub site 1";
creation.Title = "Hello sub site 1"; 
Web newWeb = context.Web.Webs.Add(creation);
// Retrieve the new web information. c
ontext.Load(newWeb, w => w.Title); 
context.ExecuteQuery();  
label1.Text = newWeb.Title;

 

 

See You in Part 2

 

 

Please follow and like us:

SharePoint Types

There are three main ways to install and use SharePoint

  • SharePoint Foundation
  • SharePoint Server
  • SharePoint Online 

SharePoint Foundation

Microsoft SharePoint Foundation is an application that is built on top of Internet Information Services (IIS) and the Microsoft ASP.NET Framework. A set of servers that run the various components of SharePoint Foundation is called a server farm. A server farm can contain multiple front-end web servers and multiple Microsoft SQL Server database servers. Each farm has its own configuration database on the database server. The configuration database contains information about the front-end web servers in a farm and administrators of the farm. In SharePoint Foundation, all the content, including user information, is stored in a content database. Every server farm can have multiple content databases

  • SharePoint Foundation is free, 
  • It includes a number of features such as security and administration, user and Team site collaboration, and a number of Apps (such as document libraries and lists).
  •  it provides a baseline set of features that enable you to get started with both using and developing for SharePoint.

SharePoint Foundation requires some features to build standard collaboration and communication solutions within your organization. The primary features of SharePoint Foundation revolve around document management and collaboration.

Key Features of SharePoint Foundation

Following are some of the major features, which are responsible for its wide adoption in businesses.

  • Effective document and task collaboration − Team websites offer access to information in a central location.
  • Reduced implementation and deployment resources − SharePoint Foundation is available to Windows Server customers as a free download, with the help of which implementation time and cost are greatly reduced.
  • Better control of your organization’s important business data − SharePoint Foundation also offers features for data and information management and security.
  • Embrace the web for collaboration − By extending and customizing SharePoint Foundation

In short, SharePoint Foundation represents the core content storage and collaboration features of SharePoint. It is the ideal edition for teams and small organizations looking to improve on their ability to work with one another in a secure, easy-to-use, collaborative workspace.

 

SharePoint Server

SharePoint Server offers a wealth of features that extend upon those offered in SharePoint Foundation. It provide a richer, more advanced collection of features that you can utilize in your organization’s solutions.

 

Key Features of SharePoint Server

Some of these additional features are described in the following list −

  • Advanced Search − The search features and functionality features available within the Server versions offer more flexibility. They allow customized Search Results pages that you can configure with customized search Web Parts.
  • Web Content Management − SharePoint Server supports web content creation and publishing for the internet.
  • Enterprise Services − These services provide ways for you to build custom solutions quickly and easily using tools that are available to you within the Office product family.
  • Business Connectivity Services − Business Connectivity Services (BCS) enables you to connect to these external data sources and display business data via Web Parts, user profiles, or SharePoint lists.
  • Social Networking and Computing − Social networking is everywhere and has become an expected feature set of many solutions.
  • Records management − SharePoint Server provides excellent support for the management of content throughout its entire life cycle.

 

SharePoint Online

SharePoint online is a fully cloud-hosted model for SharePoint. It is the alternat

e option to hosting your own farm in your own on-premises Data Center.

SharePoint-Online-with-office-365

 

Key Features of SharePoint Online

  • The options for licensing SharePoint Online through Office 365 are based on factors such as the number of users you want to add, the amount of data you need to store, and the features you need to be available.
  • It has also become a great place where you can develop rich applications (both as SharePoint-hosted and cloud-hosted apps) and scale without the cost of managing the on-premises infrastructure.
  • It does not have all the same services and features as SharePoint Server, but does carry with it some great development capabilities.
  • There are .NET applications that you build using C# or Visual Basic and then deploy into SharePoint as .WSPs or .APPs. There are lighter-weight apps such as HTML5 and JavaScript apps that you can also deploy.
  • As a developer, you have the capability to customize any of the SharePoint editions, whether it is SharePoint Foundation, Server, or Office 365.

 

Please follow and like us:

What is SharePoint

Microsoft SharePoint is a popular business platform that supports a wide variety of projects, from simple document management solutions to networking portals and Internet sites

. Using SharePoint, you can manage your colleague’s and your own documents, social activities, data, and information.

  • It allows groups to set up a centralized, password-protected space for document sharing.
  • Documents can be stored, downloaded and edited, then uploaded for continued sharing.
  • SharePoint offers such a wide array of features that it is very challenging for any one person to be an expert across all the workloads.

Let us understand what all can we do with SharePoint. It is divided into three separate areas −

Collaboration

The term collaboration contains a very strong theme for SharePoint. It means bringing people together through different types of collaboration, such as enterprise content management, Web content management, social computing, discoverability of people and their skills.

  • In SharePoint 2013, collaboration is managed through Apps.
  • Developers can extend, customize, or build their own Apps for SharePoint as well manage collaboration on SharePoint.

Interoperability

SharePoint is also about bringing this collaboration together through interoperability such as −

  • Office and web-based document integration.
  • Capability to build and deploy secure and custom solutions that integrate line-of-business data with SharePoint and Office.
  • Integrating with wider web technologies, or deploying applications to the cloud.

Platform

SharePoint is also a platform that supports not only interoperability and collaboration but also extensibility, through a rich object model, a solid set of developer tools, and a growing developer community.

  • One of the key paradigm shifts is the notion of the cloud in SharePoint.
  • The cloud introduces new App models such as −
    • New ways of developing, deploying, and hosting SharePoint applications.
    • New forms of authentication through OAuth.
    • New ways of data interoperability using OData and REST.
Please follow and like us: