Quantcast
Viewing all articles
Browse latest Browse all 463

LINQPad 4/5 Driver for Dynamics CRM Web API is available on CodePlex

I am pleased to announce that we released “LINQPad 4 and 5 Driver for Dynamics CRM Web API” on CodePlex.

https://crmlinqpadwebapi.codeplex.com/

What’s LINQPad?

LINQPad (http://www.linqpad.net/) is a great tool which you can write and execute LINQ query against many data sources, like SQL Server, Oracle or Web Services. In addition to LINQ query support, the tool also supports C#/F#/VB expression, statement block or program, to write and execute the code and code snippet.

What can you do with CRM Driver?

This driver does several things.

- LINQ query against Dynamics CRM organization
- Execute Web API action and function
- Register application to Azure AD for CRM Online

This driver works with Dynamics CRM 2016 On-Premise, IFD and Online, which supports Web API.

Install Driver to LINQPad 4 or 5

1. Download and install LINQPad if you don’t have it yet from http://www.linqpad.net/

2. Go to https://crmlinqpadwebapi.codeplex.com/ and click “DOWNLOADS” tab, then download CRMLinqPadDriverWebAPI.lpx file.

3. Open LINQPad and click “Add connection” link on top left.

Image may be NSFW.
Clik here to view.
image

4. Click “View more drivers…” button at the bottom of the page.

Image may be NSFW.
Clik here to view.
image

5. Click “Browse” button in the bottom of the page.

6. Select downloaded CRMLinqPadDriverWebAPI.lpx file, then click “Open”.

7. Click OK.

Image may be NSFW.
Clik here to view.
image

Register an application

For IFD environment, you have to register an application before using the driver.

1. Login to AD FS server (You need to use Windows Server 2012 R2 AD FS or later).

2. Open PowerShell

3. Run the following command. You can change name and Guid, but please keep RedirectUri as the driver expects the value.

> Add-AdfsClient -ClientId 5ee98d47-38d1-4db5-b5c2-9a60f88c0076 -Name "CRM For Linqpad" -RedirectUri http://localhost/linqpad

4. Note the ClientId as you use it later.

For Dynamics CRM Online, the driver automatically register an application on your behalf if you have privilege. Otherwise, you can register an application to another Azure AD environment and use consent feature. In that you, you need to register an application in advance and obtain ClientId. Please see following article for detail how to register an application.

https://msdn.microsoft.com/en-us/library/mt622431.aspx

Use the Driver

1. Select “Dynamics CRM Web API Linq Pad Driver” in Choose Data Context and click “Next”.

Image may be NSFW.
Clik here to view.
image

2. For IFD, or if you have ClientId, then uncheck “Register to Azure AD automatically” on the top, and enter ClientId.

Image may be NSFW.
Clik here to view.
image

Otherwise, leave the checkbox checked.

3. Click “Login to CRM” and login to your Organization at login screen.
Select correct combination for login.

Image may be NSFW.
Clik here to view.
image

4. If you didn’t pass ClientId for Online environemnt, then it tries to register application to get ClientId. If your user account doesn’t have enough privilege, you may need to ask Azure AD admin to login or let them register and give you the ClientId.

Image may be NSFW.
Clik here to view.
image

5. Then, it’s downloading data content and generates models. For IFD or consent mode, you will be prompted for authentication.

Image may be NSFW.
Clik here to view.
image

6. Once “Loading Data” completed, click “Exit”. Then LinqPad starts loading schema, which takes a bit of time. Wait until you see schema information on the left pane like below screenshot.

Image may be NSFW.
Clik here to view.
image

Write LINQ query and Execute

1. Firstly, select added connection from “Connection” dropdown on the top right.

Image may be NSFW.
Clik here to view.
image

2. Enter LINQ query to query window.

Image may be NSFW.
Clik here to view.
image

3. Click “Play” button or press F5 key to execute query. You will see the result in result pane.

4. Click SQL tab in result pane, where you can find Web API Url for the query.

Image may be NSFW.
Clik here to view.
image

Use Key for navigation

To use navigation, you can use ByKey to specify single record.

1. Enter following Query by changing account id to match your record.

Image may be NSFW.
Clik here to view.
image

2. Execute and see the result.

Image may be NSFW.
Clik here to view.
image

This is equivalent URL displayed in SQL Tab.

https://crm2016training8.crm7.dynamics.com//api/data/v8.0.1.79/accounts(69e3ec47-60d5-e511-80e3-c4346bc4ef3c)/contact_customer_accounts?$select=fullname

Execute Unbound Function

To execute Unbound Function, follow the steps below.

1. Change Language to “C# Statement”.

Image may be NSFW.
Clik here to view.
image

2. Enter following code to execute WhoAmI function.

Image may be NSFW.
Clik here to view.
image

3. Execute and see the result.

Image may be NSFW.
Clik here to view.
image

This is equivalent URL displayed in SQL Tab.

https://crm2016training8.crm7.dynamics.com//api/data/v8.0.1.79/WhoAmI()

Execute Bound Function

To execute Bound Function, follow the steps below.

1. Enter for following query, which use navigation of user and call function on it. Replace systemuserid to your user id, which you get from previous function.

Image may be NSFW.
Clik here to view.
image

2. Execute and see the result.

Image may be NSFW.
Clik here to view.
image

This is equivalent URL displayed in SQL Tab.

https://crm2016training8.crm7.dynamics.com//api/data/v8.0.1.79/systemusers(8dd78a80-c930-490a-bf06-64e57804b276)/Microsoft.Dynamics.CRM.RetrieveUserPrivileges()

Actions

Actions works similar ways to Function.

What’s next?

We would like to hear feedback from you!! As it’s open source, you are able to extend it to your own needs, or you can suggest/report bugs.

Ken
Premier Mission Critical/Premier Field Engineer
Microsoft Japan


Viewing all articles
Browse latest Browse all 463

Trending Articles