Code samples for SharePoint

Find and download code samples for SharePoint, including samples that demonstrate SharePoint Add-ins, user experience design, metadata management, workflows, mobile application development, REST, and other areas of SharePoint development.

Code samples for SharePoint and SharePoint Add-ins

Title Summary Subject
SharePoint: Creating an OData source With BCS notifications
Learn how to create a Windows Communication Foundation (WCF) data service that exposes data from the Northwind database using the OData protocol to provide data, as well as notifications of changes to that data found in the external system.
BCS, OData, WCF
SharePoint: MyFileConnector custom BCS indexing connector sample
Learn how to create a custom BCS indexing connector for Search in SharePoint.
BCS
SharePoint: Set the Bing Maps key by using the client object model
Set the Bing Maps key at the farm or web level using the client object model.
CSOM, SharePoint Add-ins
SharePoint: Hello World remote app using CSOM
Learn how to create a basic "hello world" provider-hosted SharePoint Add-in that uses the SharePoint CSOM to read information about a SharePoint site from a remote web application.
CSOM, SharePoint Add-ins
SharePoint: Get list items by using the cross-domain library (CSOM)
Learn how to use the cross-domain library in SharePoint Add-ins to read items in a list hosted in the app web.
CSOM, data access, SharePoint Add-ins
SharePoint: Perform basic data access operations by using CSOM in apps
Learn how to use the SharePoint CSOM to perform basic data access operations (Create, Read, Update, Delete) on SharePoint lists and list items.
CSOM, CRUD
SharePoint: Automate tagging fields with terms (CSOM)
Learn how to tag documents in SharePoint by using the .NET client object model (CSOM).
CSOM, ECM
SharePoint: Get data from a remote service using the web proxy
Learn how to read data in a remote service from a SharePoint webpage by using the web proxy in SharePoint Add-ins.
Data access, SharePoint Add-ins
SharePoint: Get data by using a proxy page for the cross-domain library
Learn how to read data in a remote service from a SharePoint webpage by creating a custom proxy page for the cross-domain library in SharePoint Add-ins.
Data access, SharePoint Add-ins
SharePoint: Automate tagging fields with terms (server object model)
Learn how to tag documents in SharePoint by using the .NET server object model.
ECM, server object model
SharePoint: Column usage report
Learn how to create a column usage report for a specified SharePoint site.
ECM, metadata management
SharePoint: Content type report
Learn how to build a custom report that shows how content types are used on a specific SharePoint site.
ECM, metadata management
SharePoint: Import a term set from an external source
Learn how to import a term set that is stored in XML format from an external data source.
ECM, metadata management
SharePoint: Synchronize term sets with the term store (CSOM)
Learn how to synchronize SharePoint term sets with the term store by using the .NET client object model (CSOM).
ECM, metadata management, CSOM
SharePoint: Synchronize term sets with the term store (server object model)
Learn how to synchronize SharePoint term sets with the term store by using the .NET server object model.
ECM, metadata management, server object model
SharePoint: XML object snapshot
Learn how to use reflection to crawl a SharePoint site and write a snapshot of the site's objects and properties into a report in XML format.
ECM, metadata management
SharePoint: Extract and insert bin-unit elements in XLIFF files
The BinarySample tool provides a simple means of extracting and inserting binary content from an XLIFF file produced from a SharePoint publishing site.
ECM
SharePoint: Use event receivers to handle events in apps for SharePoint
Learn how to handle events in an SharePoint Add-in by using the SharePoint development tools in Visual Studio 2010.
Event receivers, SharePoint Add-ins
SharePoint: Create a remote event receiver for external data
Learn how to create a remote event receiver that performs actions based on changes in external data.
Event receivers, data access
SharePoint: Accessing complex external content types with CSOM
Learn how to use client code libraries to manipulate app-scoped external content types.
External content types, CSOM
SharePoint: Create external list based on app scoped external content type
Learn how to create a new external content type based on an OData source and an external data list to display the data from the external system.
External content types, OData
SharePoint: Create multiple external lists with associations
Demonstrates how to create an external content type using multiple associated entities, and display that data in multiple external lists.
External content types, SharePoint Add-ins
SharePoint: Create custom Geolocation field type with client-side rendering
Use client-side rendering technology in SharePoint to customize a Geolocation field type.
Geolocation
SharePoint: Add a Geolocation column to a list programmatically
Add a GeoLocation column to a list in SharePoint programmatically.
Geolocation
SharePoint: Programmatically create a map view with Geolocation field type
Learn how to use the new Geolocation field type to integrate location information and maps in a SharePoint list and create location-based map views.
Geolocation
SharePoint: Create a Geolocation field that renders maps using Nokia Maps
Render data from Nokia maps in SharePoint by creating a custom field type that inherits from the Geolocation field type.
Geolocation, mobile development
SharePoint: Get the host web title using the cross-domain library (JSOM)
Learn how to use the cross-domain library in SharePoint Add-ins to read the host web title by using the JavaScript object model (JSOM).
JSOM, SharePoint Add-ins
SharePoint: Execute basic tasks using the JavaScript object model (JSOM)
Learn how to perform basic tasks using the JavaScript object model (JSOM) in an SharePoint Add-in. This sample also shows how to use the JSOM in a SharePoint-hosted html page.
JSOM, SharePoint Add-ins
SharePoint: Access Machine Translation Service from Silverlight application
Learn how to translate document libraries, single documents or folders, and text streams with the Machine Translation Service in SharePoint using the Silverlight client object model.
Machine translation, Silverlight, SharePoint Add-ins
SharePoint: Access Machine Translation Service using server object model
Learn how to translate document libraries, single documents or folders, and text streams with the Machine Translation Service in SharePoint using the server object model.
Machine translation, SharePoint Add-ins, server object model
SharePoint: Access Machine Translation Service using the CSOM
Learn how to translate document libraries, single documents or folders, and text streams with the Machine Translation Service in SharePoint using the .NET client object model.
Machine translation, CSOM, SharePoint Add-ins
SharePoint: Accessing the Machine Translation Service with JavaScript
Learn how to translate document libraries, single documents or folders, and text streams with the Machine Translation Service in SharePoint using the JavaScript client object model.
Machine translation, JavaScript, SharePoint Add-ins
SharePoint: Assign new settings to a navigation term set (.NET server)
Shows how to assign new settings to a navigation term set using .NET server managed code.
Metadata management, server object model
SharePoint: Assign new settings to a navigation term set using CSOM
Shows how to assign new settings to a navigation term set using the CSOM.
Metadata management, CSOM
SharePoint: Create a Windows Phone app to receive push notifications
Create a Windows Phone app for receiving notifications from a SharePoint list.
Mobile development
SharePoint: Customize the UI of a SharePoint list app for Windows Phone
Customize the Windows Phone user interface that is generated by the Windows Phone SharePoint List Application template.
Mobile development, UI design, user experience
SharePoint: Export the Name field in a Document Library list to a mobile app
Export the "Name" field of a document library list to a mobile app by using the Visual Studio SharePoint List wizard.
Mobile development
SharePoint: Support and convert SharePoint field types in Windows Phone app
Implement data-conversion logic to support SharePoint field types in Windows Phone apps.
Mobile development
SharePoint: Create a simple external list-based phone app
Create a simple mobile app that contains data from an external data source by using Business Connectivity Services and an external list.
Mobile development, BCS
SharePoint: Create a phone app that displays Maps for SharePoint
Integrate location information and maps into SharePoint lists and location-based web and mobile apps for SharePoint by using the new Geolocation field.
Mobile development
SharePoint: Store and retrieve SharePoint list items on a Windows Phone
Learn about one of the most important considerations in the development of Windows Phone apps, the management of state information, both for the overall application and for individual pages or data items within the application.
Mobile development
SharePoint: Use multiple SharePoint lists in a Windows Phone app (sample 1)
Create Windows Phone apps that use data from multiple SharePoint lists.
Mobile development
SharePoint: Use multiple SharePoint lists in a Windows Phone app (sample 2)
Create Windows Phone apps that use data from multiple SharePoint lists.
Mobile development
SharePoint: Create push notifications in SharePoint for Windows Phone apps
Create a solution in SharePoint for sending push notifications that can be received by Windows Phone apps.
Mobile development
SharePoint: Implementing business logic and data validation
Implement data validation in a Windows Phone app created by using the Windows Phone SharePoint List Application template.
Mobile development
SharePoint: Make app-only policy type calls in a remote app (CSOM)
Uses the AllowAppOnlyPolicy attribute and makes app-only policy type calls. It uses OAuth to call back into SharePoint Server. Sample uses CSOM.
OAuth, CSOM
SharePoint: Make app-only policy type calls in a remote app (REST)
Uses the AllowAppOnlyPolicy attribute and makes app-only policy type calls. It uses OAuth to call back into SharePoint. Sample uses REST.
OAuth, REST
SharePoint: Use HTTPS in a remote app
Contains a remote app that uses HTTPs protocol. It uses OAuth to call back into SharePoint.
OAuth
SharePoint: Perform basic data operations on files and folders using REST
Learn how to use Representational State Transfer (REST) and the SharePoint JavaScript cross-domain library to perform basic operations on document libraries and files.
REST, data access
SharePoint: Get the host web title using the cross-domain library (REST)
Learn how to use the cross-domain library in SharePoint Add-ins to read the host web's title by using the Representational State Transfer (REST) service.
REST, SharePoint Add-ins
SharePoint: Build REST queries and use REST to traverse a site
Learn how to use the SharePoint REST APIs to traverse a SharePoint site, and to create an app that builds queries that perform basic data operations (Create, Read, Update, and Delete) on basic SharePoint entities that are exposed at REST endpoints.
REST, CRUD, SharePoint Add-ins
SharePoint: Perform basic data access operations by using REST in apps
Learn how to use the SharePoint REST APIs to perform basic data access operations (Create, Read, Update, Delete) on SharePoint lists and list items.
REST, data access, CRUD
SharePoint: Create an app to access a public OData source
Learn how to create an app-scoped external content type and access that data using the REST API.
REST, SharePoint Add-ins
SharePoint: Accessing external lists with REST
Learn how to create an SharePoint Add-in that will use RESTful URLs to query and manipulate data in an external list.
REST, SharePoint Add-ins
SharePoint: Using the search REST service from an app for SharePoint
Learn how to submit a search query to Search in SharePoint from within an SharePoint Add-in.
REST, search, SharePoint Add-ins
SharePoint: Get list items by using the cross-domain library (REST)
Learn how to use the cross-domain library in SharePoint Add-ins to read items in a list hosted in the app web.
REST, SharePoint Add-ins
SharePoint: Hello World remote app using REST
Learn how to create a basic "hello world" provider-hosted SharePoint Add-in that uses the SharePoint REST interface to read information about a SharePoint site from a remote web application.
REST, SharePoint Add-ins
SharePoint: Mix remote web applications with SharePoint components in apps
Shows how to combine a remote web application and classic SharePoint components in a single SharePoint Add-in. Also shows how remote web applications can access the app web using REST/OData.
REST, OData, SharePoint Add-ins
SharePoint: Customize a field type by using client-side rendering
Uses client-side rendering technology in SharePoint to customize a field type.
UI design, user experience, SharePoint Add-ins
SharePoint: Customize a list view by using client-side rendering
Uses client-side rendering technology in SharePoint to customize a view in an announcements list.
UI design, user experience, SharePoint Add-ins
SharePoint: Bookstore, using custom actions and the cross-domain library in a sample
Simulates a bookstore by using a SharePoint document library in which every document is a book. End users can request new books and buy books by using the provided custom actions.
UI design, user experience, custom actions
SharePoint: Display remote webpage content using the coffeemaker app part
Includes an app part that displays a remote webpage's content. The remote page content consists of labels and images for a coffee cup. End users can further customize their coffee through the custom properties in the app part.
UI design, user experience, SharePoint Add-ins
SharePoint: Open a remote app webpage using a Ribbon custom action
Includes a Ribbon custom action that passes the SharePoint website URL, List ID, and selected Item IDs from where it is invoked to a remote webpage.
UI design, user experience, SharePoint Add-ins
SharePoint: Use the chrome control in a cloud-hosted app
This SharePoint code sample includes a remote webpage that hosts the chrome control.
UI design, user experience, CRUD, SharePoint Add-ins
SharePoint: Use the SharePoint style sheet in an app
This code sample references the SharePoint style sheet control in a remote webpage and uses the available styles.
UI design, user experience, SharePoint Add-ins
SharePoint: Use the chrome control and the cross-domain library (CSOM)
Includes a remote webpage that hosts the chrome control and retrieves information from the host web using the cross domain library and the CSOM in SharePoint.
UI design, user experience, CSOM, SharePoint Add-ins
SharePoint: Use the chrome control and the cross-domain library (REST)
Includes a remote webpage that hosts the chrome control and retrieves information from the host web using the cross domain library and Representational State Transfer (REST) in SharePoint.
UI design, user experience, REST, SharePoint Add-ins
SharePoint: Open a remote app webpage using an ECB custom action
Includes an ECB (Edit Control Block) custom action that passes the SharePoint website URL, List ID, and Item ID from where it is invoked to a remote webpage.
UI design, user experience, SharePoint Add-ins
SharePoint workflow: Call an external web service
Find out how to use Visual Studio 2012 to create a SharePoint workflow that calls an external web service. When calling the web service, the workflow also uses the new DynamicValue data type.
Workflows
SharePoint workflow: Create a custom action
Learn how to use Visual Studio 2012 to create a SharePoint workflow that uses a custom action and calls an external web service. When calling the web service, the workflow uses the new DynamicValue data type.
Workflows
SharePoint workflow: Integrate with Netflix
Learn about using Visual Studio 2012 and Workflow Manager Client 1.0 to create a workflow that uses a web service workflow activity with an OData query to access the Netflix service.
Workflows, OData
SharePoint workflow: Sales tax calculator
Learn about using Visual Studio 2012 and Workflow Manager Client 1.0 to create a workflow that calls a web service to obtain the sales tax rate for a given location. It then calculates the sales tax based on the base price in a product catalog.
Workflows
SharePoint workflow: Using task action
Illustrates how to use the new Task Actions feature that was added to SharePoint Designer 2013 for enhanced workflow design and development.
Workflows
SharePoint: Display remote app content in the host web using an app part
Includes a simple page hosted in a remote app. The app part displays the contents of the remote webpage and sends the value of the custom properties through the query string.
SharePoint Add-ins
SharePoint: Hello World SharePoint-hosted app
Learn how to create a basic SharePoint-hosted SharePoint Add-in that uses JavaScript to read and display information about a SharePoint site.
SharePoint Add-ins

Additional resources