16 Feb’16

Dynamics CRMAuto Complete feature in CRM 2016

Introduction

In this blog we are going to discuss about the new Auto completion feature of CRM 2016. First, a disclaimer – the term ‘autocomplete’ might be a bit misleading since the field is not automatically completed but instead you can select the suggested item from the list.

Requirement

To use the Country text field on the address section of the Account and Contact record to enter the Country but restricting users from entering any random values. Instead, the users need to enter country codes only. The goal was to accomplish this without using lookup field on the form.

For the text fields, the auto complete feature was not available in previous CRM versions. Hence instead of using text fields, we used to have either lookup fields (for many items) or option set fields (for limited set of options).

Solution

In CRM 2016, new methods are introduced for text fields. Using these methods, we can implement auto complete feature for text fields, where users can see the suggestions and either select any option or type its own value.
 
1. showAutoComplete
This method allows us to show list of possible values as dropdown to add auto complete feature to text fields. As soon as we select any item under the list, it will be populated in target text field and OnChange event of that field will fire.

Use this to show up to 10 matching strings in a drop- down list as users press keys to type character in a specific text field.

Also add a custom command with an icon at the bottom of the drop down list.

The above method can be used as follows:

Xrm.Page.getControl(field name).showAutoComplete(object);

This method takes object as parameter which includes results and command.

Object can be defined like below:

var resultset = { 
   results: [{ 
         id: <value1>, 
         icon: <url>, 
         fields: [<fieldValue1>]}], 
   commands:{ 
         id: <value>, 
         icon: <url>, 
         label: <value>, 
         action: <function reference> 
         } 
 }

Here, the result represents an array of possible values that we want to show under the drop down on keypress. Under the results, we can define id, for individual array item, icon to show particular icon for array items and the field where we pass values.

Commands is used to define additional action on the drop down, for example opening any additional page by providing a link.

 
2. hideAutoComplete
This method is used to hide the auto complete drop down list that is implemented using showAutoComplete method.

No need to explicitly use this method because, by default, the drop down list hides automatically if the user clicks elsewhere or if a new drop down list is displayed.

The above method can be used as follows:

Xrm.Page.getControl(field name).hideAutoComplete()

Note: Both of above methods only works with Web and Outlook client.

Steps for creating an auto complete feature on single line text field are as follows:

  1. Save and publish script event OnLoad of the form.
  2. When user is going to type some character in auto complete text field, drop down list will display the list of records present. It will show only the first 10 results which are suggested.
  3. When user types some character in auto complete text field, the list of results matching the characters is shown in the drop-down.

Advantages:

This feature is useful when we have a master list of data from which users can select the value, at the same time users can also put data if they don’t find value in the master list.

Lookup approach was restricting users from selecting data only from master list and was not allowing users to put their own values.

One of the best example to this is list of Cities. Users can either select city from master list or if city is not available, then they can put their own value.

Current Limitations:

  1. Autocomplete does not work on phone/tablet native apps yet.
  2. Autocomplete works only on updated entity forms.

We hope this blog have given you useful information on the new Auto Complete feature of CRM. Contact us for any queries!

 

Written by

Team Member

CloudFronts

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.

Want to streamline your business processes?

  • This field is for validation purposes and should be left unchanged.

Recent Articles

  • Reading more then 10K records in D3FOE OData API

    11 July’ 2018

    Introduction: We all know Dynamics 365 Finance and Operations has limitation of 10K records to be fetched at a time usi...

    Read more
  • Paging in D365 Customer Engagement v9.0

    10 July’ 2018

    Introduction: The Xrm.retrieveMultipleRecords method is used to retrieve a collection of records in Dynamics 365 Custom...

    Read more
  • Set up Dynamics 365 connection in Microsoft Social Engagement

    10 July’ 2018

    Introduction: This blog explains how to Set up Dynamics 365 connection in Microsoft Social Engagement. Steps to be follo...

    Read more
  • Voice of the Customer failed to install

    10 July’ 2018

    Introduction: Many people face issues in installing Voice of Customer solution on v9 environment and trying repeatedly ...

    Read more
  • Scribe Insight AX as a Web Service Find Block issue

    10 July’ 2018

    Introduction: If we need to look up for any value from AX then we do it by using a Find Block in Scribe Insight Eg: Basi...

    Read more