Microsoft Dynamics CRM 2016 introduced two new CRM client-side API additions: Web API and Autocomplete. In today’s blog, we will go over both of these new features and show you how they can be used. Let’s get started!
The Web API is replacing the Organization Service. It implements OData v4, which allows the same operations as the Organization Service without needing CRM SDK assemblies. This is a BIG deal, as complex applications can be created across a variety of platforms and programming languages without the limitation of OData v2 CRUD only operations. Actions and Functions are operations performed via HTTP requests. The Organization Service (OData v2 REST endpoint) has been deprecated for CRM 2016.
Here is where you find the new Web API URL: Settings à Customizations à Developer Resources.
Want to learn more about the new Web API? Check out this blog post!
Autocomplete was added to the API in Dynamics CRM 2016. It provides a quick and easy way to pick a value from a predefined list, improves the user experience in forms, and helps with data quality in the system.
In out-of-the-box CRM, the Address fields are all plain text. Country, State and Zip Code fields are good candidates for autocomplete fields. In the steps below, we will demonstrate how to retrieve Countries from a custom entity via the Web API and display it on an autocomplete field. Autocomplete data source is not limited to custom entities. External sources can be used as well.
The setup: Country entity with Name and Country ISO Code fields:
Register the loadAutoComplete function in the Form Load event:
The code: The function below retrieves all Country names and codes, sorted by country name, form the custom po_country entity and calls the autoCompleteCountries function passing the list of countries as a parameter.
The function autoCompleteCountries is implemented with the code below. The autocomplete feature is simple to use, but please note that two methods and one event handler are needed: addOnKeyPress, showAutoComplete and hideAutoComplete.
- showAutoComplete: Displays the autocomplete drop-down field when there is a match between what the user typed in the Address1: Country/Region field and any Country name or ISO code.
- hideAutoComplete: Hides the autocomplete drop-down field when no matches are found.
- addOnKeyPress: The keyPressFcn is called every time a user types a character in the Address1: Country/Region field.
This is what it all looks like in action:
Check out the video here to see it all in action:
That’s all for the blog today! Keep coming back for more information on the great new features of Microsoft Dynamics CRM.