Hi all,
I was able to auto populate a string field in order to get right suggestions using addOnkeyPress,
I need to get the selected value so I call the changeAutocomplete() during the OnChange field event
but in the alert, I get just what the user wrote in the field and not the complete resultSet value of my autocomplete array values.
I need "Matteo" in the alert and not only "m".
var keyPressFcn = function (ext) {
try {
var userInput = Xrm.Page.getControl("tclab_casepriority").getValue();
resultSet = {
results: new Array(),
commands: null
};
var userInputLowerCase = userInput.toLowerCase();
for (i = 0; i < persona.length; i++) {
if (userInputLowerCase === persona[i].name.substring(0, userInputLowerCase.length).toLowerCase()) {
resultSet.results.push({
id: i,
fields: [persona[i].name,persona[i].code
]});
}
}
if (resultSet.results.length > 0) {
ext.getEventSource().showAutoComplete(resultSet);
}
else {
ext.getEventSource().hideAutoComplete();
}}
catch (e) {
console.log(e);
}};
var a = Xrm.Page.getControl("tclab_casepriority");
if (a!=null) {
a.addOnKeyPress(keyPressFcn)
}}
function changeAutocomplete() {
var b = Xrm.Page.getAttribute("tclab_casepriority").getValue();
//This is happening also using getControl method
// var b = Xrm.Page.getControl("tclab_casepriority").getValue();
alert(b);
}


At The end I will need also to do the same thing with the Case Severity field, filtering auto-populate suggestions based on the CasePriority autocomplete field. I think when I will get the right value I would replicate the autocomplete also for the case severity field.
THANK YOU IN ADVANCE FOR YOUR SUGGESTIONS