Five code samples to help you get started with apps for SharePoint

I’m Jim Crowley, a senior programming writer who works on SharePoint developer documentation. My team has been working on a number of resources, articles, and samples aimed at introducing the SharePoint 2013 app model to a wide audience of developers, some of whom may be new to SharePoint, and all of whom will be new to this kind of SharePoint development.

The SharePoint 2013 app model provides developers with a lot of flexibility and choice, and its embrace of web standards creates a new model of SharePoint development that looks a lot more like standard web development. Because the model is new, some pieces of it will look unfamiliar to experienced SharePoint developers. Additionally, its openness to web standards makes the SharePoint platform more appealing to experienced web developers who may not be especially familiar with SharePoint as a development platform.

No matter what kind of developer you are, you will need to introduce yourself to the new model and the possibilities that it enables. The five code samples listed below provide quick introductions to some of the most important concepts and capabilities of app development in SharePoint. This post focuses on those samples that get you up and running as quickly as possible and that concentrate on new core capabilities and features of the app model.

Hello World remote app using CSOM

This simple app demonstrates how to set up a basic provider-hosted app that uses the SharePoint client object model to retrieve basic information about a SharePoint site from a remotely hosted web application. It also introduces you to fundamental components of a provider-hosted app, such as the AppManifest.xml file and the web.config file of the remote web application.

Use event receivers to handle events in apps for SharePoint

Remote event receivers are an important feature of the app model. They enable the remotely hosted components of a provider-hosted SharePoint app to respond to events that occur on entities, such as lists and list items, on a SharePoint site. This sample shows you how to create and use a remote event receiver that handles events on list items. Because it is an extension of the Perform basic data access operations by using CSOM in apps sample, it also introduces you to some fundamental create, read, update, and delete (CRUD) operations that you can do with the SharePoint client object model.

Get data from a remote service using the web proxy

The new app model provides an easy way to integrate information from remote (non-SharePoint) web services into your apps. This sample demonstrates how to use the SharePoint 2013 web proxy to read data from Bing and display it in a SharePoint-hosted app. This sample is also a good introduction to SharePoint-hosted apps and the SharePoint JavaScript object model.

Get list items by using the cross-domain library (REST)

The SharePoint 2013 cross-domain library is a convenient tool for JavaScript developers who need to access SharePoint data from a remote location and who therefore also need to overcome cross-site scripting restrictions. This sample reads and displays information from a SharePoint announcements list in a remotely hosted web application written in JavaScript. Because it reads SharePoint data by using the enhanced SharePoint 2013 Representational State Transfer (REST) interface, it is also a good introduction for developers who are interested in using REST instead of the SharePoint  JavaScript and client object models.

Display remote app content in the host web using an app part

A provider-hosted app accesses information from a SharePoint site and uses it in a remotely hosted web application. The app model makes it possible to complete the circle by creating provider-hosted apps that users can find and add to their SharePoint sites in the same way that they find and add other kinds of SharePoint Web Parts. This sample shows you how to create this sort of app and access the custom properties that users set on it. Once you install and run it, you can find it in the Web Part Gallery of your SharePoint site.

 

You can find these samples and dozens more by going to the Apps for Office and SharePoint Samples page in the MSDN Code Gallery and applying the apps for SharePoint filter. If you find any other samples especially useful or have ideas for additional samples, please let
us know in the comments section.