Create a mobile app in SharePoint that contains data from an external data source
Learn how to create a simple mobile app in SharePoint that contains data from external data source by using Business Connectivity Services and connecting to an external list. SharePoint enables you to build mobile applications that can access external data from databases, enterprise applications, and Web 2.0 services using Business Connectivity Services. You can also provide complete interaction with the external data including write-back capabilities from your mobile device. You do this by creating apps that connect to external lists, which are a special type of lists in SharePoint that are based on external content types and contain data from an external system. The new Windows Phone SharePoint List template in Visual Studio 2010 Express enables you to quickly and easily create apps for the Windows Phone that connects to external lists. For example, you can build a Windows phone app that brings the product catalog for an inventory list in SharePoint to the phone for the sales people. This topic shows how to create a Windows Phone app that displays external data from the Northwind sample database by connecting to an external list in SharePoint. Notice that in this example, the external list connects to the Northwind database using a custom OData service; however, it's possible to connect to databases directly as well as any external system that is supported by Business Connectivity Services, using external lists. With the new SharePoint List template in Visual Studio, you can create a mobile app that can access an external list on a SharePoint site. This article provides a step-by-step procedure that begins with uploading an external Business Data Connectivity (BDC) service model and ends with testing your new mobile app.
Important: If you are developing an app for Windows Phone 8, you must use Visual Studio Express 2012 instead of Visual Studio 2010 Express. Except for the development environment, all information in this article applies to creating apps for both Windows Phone 8 and Windows Phone 7. > For more information, see How to: Set up an environment for developing mobile apps for SharePoint.
Prerequisites for creating a mobile app that contains external data
A SharePoint installation with administrative privileges to upload the BDC model for the Northwind database and a SharePoint site where you create the external list
Microsoft Visual Studio Express with the new SharePoint phone templates from Microsoft SharePoint SDK for Windows Phone 7.1
The BDC model for our exampleNorthwind_oData.bdmc (download from SharePoint: Create a simple external list-based phone app)
A SharePoint installation with administrative privileges to upload the BDC model for the Northwind database and a SharePoint site where you create the external list
Step 1: Upload a BDC metadata model
A BDC model is the core of Business Connectivity Services. It's an XML file that uses data structures such as Entity (external content type) and Method to abstract out complex details about the external system. It's auto-generated when you create an external content type using SharePoint Designer and for some data source types such .NET and OData sources, you need to create the BDC model manually or by using Visual Studio. When you upload a BDC model to the BDC metadata store using SharePoint Central Administration, the external content types defined in the model can be used to create external lists in SharePoint which are lists that display data from the underlying external system. In this step, you'll upload the Northwind sample BDC model to the Metadata Store using SharePoint Central Administration.
Navigate to Central Administration.
Choose Application Management, and then choose Manage Service Applications.
On the Service Application page, choose Business Data Connectivity Service.
On the ribbon in the BDC Service application, choose Import.
On the Import BDC Model page, choose Business Data Connectivity Service.
On the ribbon in the BDC Service application, choose Import.
On the Import BDC Model page, choose Browse.
In the Choose a File to upload dialog box, browse to the Northwind_oData.bdcm file, and then choose Open.
After the file is imported, choose the OK button.
Step 2: Grant permissions
Next you need to set permissions on the BDC model to specify who can execute the methods described in the model. This is a required step. We recommend that you give specific permissions to each user or group that needs them, in such a way that the credentials provide the least privilege necessary to perform the needed tasks. For more information about setting permissions, see Business Connectivity Service permissions overview in Business Connectivity Services security overview (SharePoint Server 2010). In this step, you give permission to yourself to execute the methods described in the Northwind sample BDC model.
Navigate to Central Administration.
Choose Application Management, and then choose Manage Service Applications.
On the Service Application page, choose Business Data Connectivity Service.
In the ribbon, choose BDC Models from the drop-down list in the View group.
In the list of BDC models, hover over Northwind_oData.bdcm and choose Set Permissions, as shown in Figure 1.
Figure 1. Choosing permissions for BDC model
In the Set Object Permissions dialog box, choose the Browse button.
In the Select People and Groups dialog box, search for your account and choose the OK button.
Select the permissions for Edit, Execute, Selectable In Clients, and Set Permissions, as shown in Figure 2.
Figure 2. Setting object permissions
Choose the OK button.
In the ribbon, select External Content Types from the drop-down list in the View group.
In the list of external content types, hover over Customer, and then choose Set Permissions.
In the Set Object Permissions dialog box, choose the Browse button and search for your account.
In the Set Object Permissions dialog box, choose Add and select the permissions for Edit, Execute, Selectable In Clients, and Set Permissions.
Ensure that the Propagate Permissions box is selected.
Choose the OK button.
Step 3: Create an external list
Now that you've uploaded the BDC model and set permissions, you can create an external list based on the external content type defined in the BDC model. In this step, you will create an external list based on the Customer external content type defined in the Northwind BDC model you uploaded in Step 1: Upload a BDC metadata model.
Navigate to the SharePoint site where you want the new list.
On the home page of the site, choose More.
On the Apps page, choose Add an App.
On the Add an App page, hover over External List and choose Add it.
In the Adding an External List dialog box, enter a name such asCustomers in the Name field.
In the External Content Type box, specify the external data source that you uploaded in step 1.
Choose the OK button.
On the Apps page, choose Customers List to view the list.
Step 4: Create a mobile app using the Windows Phone SharePoint List Application template
Your external list is ready and you can now create a Windows Phone 7 app that connects to the external list you created in Step 3: Create an external list and display Customer data from the Northwind database.
Start Visual Studio 2010 Express.
On the menu bar, choose File, New Project. The New Project dialog box opens.
In the New Project dialog box, choose Visual C#, choose Silverlight for Windows Phone, and then choose Windows Phone SharePoint List Application.
Specify a name for the project. We use CustomerApp in this example, as shown in Figure 3.
Figure 3. Selecting the Windows Phone SharePoint List Application template in Visual Studio
Choose the OK button.
In the SharePoint Phone Application Wizard, enter the URL of the SharePoint site in which you created the external list.
Choose the Customers list, and choose Next.
On the Choose Views screen, select Customer Read List and choose Next.
On the Choose Operations screen, choose Display, and then choose Next.
On the Choose Fields screen, select the fields you want to use or display in your mobile app, and then choose Next.
On the Order Fields screen, reorder the fields if needed, and then choose Finish.
You've now successfully created the app that connects to the external list.
Run and test your app
Now that the app is ready to run, you can test it using phone emulator.
In Visual Studio, choose Debug, and then choose Start Debugging, or press F5.
When prompted, log in by using the same username and password that you used to log in to the SharePoint site. Ensure that you have admin rights.
Scroll through the resulting Customers list, as shown in Figure 4.
Figure 4. Mobile app displaying SharePoint external list
Note
When you use the SharePoint List Template wizard to create a mobile app for an external list that has read-only fields, the code that is generated by the wizard does not allow users to create or edit items.