The power of Project Siena comes from its ability to rapidly build an app and connecting to data from a variety of REST sources. In this post, we are going to walk through the steps required to connect Project Siena to Microsoft Dynamics CRM Online. Dynamics CRM Online exposes an OData head and Project Siena can connect to this endpoint to query or submit data.

Let’s illustrate a sales scenario – Fabrikam is a software company selling software to large enterprise customers. Their sales force manage customer relationships using Dynamics CRM Online. The sales team is mobile and would like to manage their accounts and opportunities through an app. Operations they would like include:

·         View the list of active customer accounts

·         Add a new leads into the sales pipeline

·         Convert an existing lead into an opportunity

·         View the status, revenue details of existing opportunity

Here is the conceptual flow:

Dynamics CRM Online setup

If you have an existing Dynamic CRM Online account, you can skip to the next section. Otherwise follow the steps below to sign-up for a trial account from the Microsoft website.

Step 1: Navigate to the link to register for Microsoft Dynamics CRM Online Trial.

Step 2
: Create your user ID
Step 3: Enter your phone number for verification purpose.
Step 4: Add the verification code received on phone to create the account
Step 5: Note down the O365 user ID
Step 6: Update the language and currency preferences and click Finish.

Step 7
: All set, jot down the Dynamics CRM online sign-in page.
You should receive an email with the login information you just added.

Step 8: Launch a new browser window and login to Enter the user credentials added earlier.
Step 9: Once you login to the Office 365 portal, you should have Dynamics CRM and AAD configurations listed under Admin view. Click on CRM
Step 10: On the CRM Administration page, click Open.
Step 11: You have now access to the Dynamics CRM Online portal. The installation comes with sample Dynamics CRM online data which we will query later.

Azure Active Directory setup

Now we need to authorize application to access Dynamics CRM Online via AAD. To do this, you need an Azure subscription.
Step 1: Go back to the Office 365 portal (in step 9 previously) and choose Azure AD from the Admin view. If you land on the screen below, you may not have an Azure subscription.

You can always sign-up for a trial Azure subscription to proceed using the same login created for Dynamics CRM Online. After you sign-up, you can login to the Azure portal.

Step 2
: Navigate to Azure Active Directory, click on Microsoft and navigate to Applications.

Step 3
: Click on Add from the toolbar below and choose “Add an application my organization is developing”
 Step 4: In the Application UI wizard, enter a name and choose Native Client Application. Click Next.
Step 5: Enter the CRM online URL for the Redirect URI fiels. Click OK.
Step 6 The wizard should return to the application list view. Click on the created application and noted down the Client-ID. We will need the Client-ID to authorize Siena application to connect to Dynamics CRM Online.

CRM Online OData endpoint

You should now have access to Dynamics CRM Online and also setup the client ID for the application access using AAD.
Dynamics CRM Online exposes an OData interface that can be used to query or set objects. In this section we will query the interface using the browser.

Step 1: Launch a browser and enter the Dynamics CRM Online URL:

Step 2: Enter the Dynamics CRM Online user credentials created during setup
You should see a list of objects in Dynamics CRM Online. To view the individual object details, you can append names like “OpportunitySet”, “LeadSet” to the URL. For example https://<yourcompany> will show the list of leads in the browser.

Note on data format
The browser displays the XML format of the data. If you instead want to look at the JSON format, you need to set the Content-Type/Accept in the HTTP request header to application/json. This can be done using popular REST testing tools.
For example, the feed for <URL>/LeadSet is similar to the one below:
    "d": {
        "results": [{
            "__metadata": {
                "uri": "URI",
                "type": "Microsoft.Crm.Sdk.Data.Services.Lead"
                                "FirstName": "FirstName",
                                "LastName": "LastName"
                                <other parameters>

Project Siena sample WADL

We can test the setup in Project Siena using a WADL file to describe the CRM Online objects. Download the sample CRM Online WADL from the TechNet gallery

Step 1: Edit the WADL XML file in VS or your favourite XML editor. Replace the relevant sections in the WADL file with your Dynamics CRM Online URL and the Client ID.

Step 2: Open the .siena file from the sample. From the Data Sources menu, choose REST as the new source
Step 3: Browse to the WADL file and then choose Import data. Choose the GetLeads operation and click Try It.
Step 4: You should see the CRM Online login screen. Note the name "myWinApp" is the one we entered to create the client ID in the Azure Portal (Step 4-6). Login using the Dynamics CRM Online user credentials.
If you have data in Dynamics CRM Online, you should now see them in the results.

Project Siena sample app

You can create an app with the CRM Online data source. The sample siena app can query the Leads and Opportunities from Dynamics CRM Online as well as to create an opportunity. Dynamics CRM Online comes with sample data that can be used to testing. Run the app in preview mode to view this data -
  • From the Leads screen, click on the individual leads and view the status and contact information. You can also email or call the individual contact.
  • From the Opportuties screen, click on individual entries and view the customer need, situation and the proposed solution
  • From the Leads screen, click on Create opportunitya and enter details to create an opportunity. Note: you may have the reload the app to view the created opportunity inthe Opportunities screen again.