Skip to main content

Notifications

Announcements

No record found.

Auto Complete in Dynamics CRM

Following is sample JavaScript code to demonstrate the auto completion feature. This sample configures the auto-complete feature for a custom single line of text that auto complete years.





Call following function on form load event, this will auto populate the last 60 years in the field when do keypress on this field.

function year_AutoComplete() {
var keyPressFcn = function (ext) {
try {
resultSet = {
results: new Array()
};
var dt = new Date();
for (i = 0; i < 50; i++) {
resultSet.results.push({
id: i,
fields: [dt.getFullYear() - i]
});
}

if (resultSet.results.length > 0) {
ext.getEventSource().showAutoComplete(resultSet);
} else {
ext.getEventSource().hideAutoComplete();
}
} catch (e) {
console.log(e);
}
};

Xrm.Page.getControl("new_year").addOnKeyPress(keyPressFcn);
}


This was originally posted here.

Comments

*This post is locked for comments