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.

Comments (2)

  1. Adeel says:

    There are number of issue in Sharepoint's ux when rendered in IE10. Most probably this is due to the reason, SP team has chosen browser-sniffing over feature-detection (msdn.microsoft.com/…/hh475813.aspx). Consider the following issues:

    Issue 1:

    In IE10 mode, Sharepoint 2007 multiline text fields are not editable. Have to go to compatibility mode to edit them. Try to navigate to a Sharepoint 2007 list. Edit a multiline text field.This is on Win8 RTM.

    Issue 2:

    I am using "Excel web access web part" to display excel reports i n SharePoint 2010. It's working fine with IE9.But when i am loading the report in IE 10 it throwing the error "Unable to get property 'PermissionFlagsHash' of undefined or null reference " in ewamoss.js file.

    and

    when we click on the any item on the SharePoint ribbon while editing the webparts the entire page disappearing.

    Issue 3:

    When you hit any of the list item forms in SharePoint 2010, those forms will be mangled. Switch to compatibility view, and they're still manged. Forms display fine in every other browser, including non-MS browsers.

    OS is Windows 8 x64 dev preview, and ie 10 build is 10.0.8102.0 KB2587683

    ..and since so forth. Please revise the JavaScript files and make such issues go away.

    PS feature-detection is a way to go!

  2. jcrowley says:

    Sorry for the slow response to this. It might be better to address this question to one of the SharePoint forums, since it has to do with earlier versions of SharePoint (and doesn't touch on apps for SharePoint):

    social.msdn.microsoft.com/…/sharepoint