Dynamics CRM provide out of box autocomplete feature for lookup
type attributes.
But sometimes we need to show autocomplete feature in text box
also. In this blog I will try to explain how we can configure autocomplete/intellisense/google
like text box.
Expectation: -
When user click on text box it will show list of records
from where user able to select any record also append textbox. On enter any
character it should filter record based on input value.
In lookup attribute user not allowed to append value and if
we lookup value it will change all reference.
Solution: -
Classic Client:
We need JavaScript web resource to retrieve values from
source entity and function to add event to our textbox.
We have used “addOnKeyPress”, “showAutoComplete”, “hideAutoComplete”
CRM method to enable this feature.
- Create a web resource to retrieve values using web API 9.1. You can download this JavaScript file from below link.
- Create another JavaScript Web Resource which will use on Form and field. You can download this JavaScript file from below link.
Open form for which Auto complete needs to enable. I have
used Account form for example.
Click on “Form Properties” and select event tab.
Add newly created JavaScript Web Resource.
Add GetAddress1 function on load of form.
Pass
parameters in function: 'accounts','sic','sic'
Save and Publish Form.
To see result, open account record and enter value in attribute.
To download complete solution, click on below link:
UCI Client(Modern Driven App):
UCI client does not support “addOnKeyPress”, ”removeOnKeyPress”,
“showAutoComplete”, “hideAutoComplete” method . Find deprecated
list from below link.
So, we need to use Auto-Complete
control instead. It is similar to Option set but can use entity and
attribute for configuration.
Go to Form customization.
Select attribute and click on Change Properties.
Navigate to Control
section and click on Add Control button.
Select Auto Complete control and click on ‘Add’ button.
Select your client – Web, Tablet, Phone.
After that provide view or option set want to use and field information.
We can use any entity even which not have relation with current entity.
Click Ok. Save Form and publish.
Now we are ready to use auto complete control in UCI (Modern-Driven App).
UCI Limitation: -
This control does not work as it works for classic form. We can
select value but it not allowed to append value in our text box.
Share your feedback !!
No comments:
Post a Comment