Mark can implement the requirements by using the following script enhancements, introduced in Microsoft Dynamics CRM 2016:
- Keypress handler: Microsoft Dynamics CRM 2016 has introduced methods to add some JavaScript forĀ keypress events on any input fields in Microsoft Dynamics CRM 2016. Three methods can be used to assist in this regard:
- addOnKeyPress: This method can be used to add a function as an event handler for the keypress event. The syntax is as follows:
Xrm.Page.getControl(field name).addOnKeyPress(
name of function);
-
- removeOnKeyPress: This method can be used to remove a function as an event handler from the keypress event. The syntax is as follows:
Xrm.Page.getControl(arg).removeOnKeyPress(
function name);
-
- fireOnKeyPress: This method can be used to call a keypress handler. The syntax is as follows:
Xrm.Page.getControl(field name).fireOnKeyPress();
- AutoComplete handler: Microsoft Dynamics CRM 2016 has introduced methods to add JavaScript to assist in autocomplete on any input fields, such as text or number fields, in Microsoft Dynamics CRM 2016. Two methods can be used to assist in this regard:
- showAutoComplete: This method allows us to add autocomplete options on any field. The syntax is as follows:
Xrm.Page.getControl(field name)
.showAutoComplete(object);
The object parameter in the preceding syntax is an array of possible handlers, as follows:
var resultset = {
results: [{
id: <value1>,
icon: <url>,
fields: [<fieldValue1>]}],
commands:{
id: <value>,
icon: <url>,
label: <value>,
action: <function reference>
}
}
-
- hideAutoComplete: This method allows us to remove autocomplete from any field. The syntax is as follows:
Xrm.Page.getControl(field name).
hideAutoComplete ();