Henry,
Having taken your advice I am now using Visual Studio Code and I got one the previous script working, however I am still not very far up the curve. Could I push you for a little more help?
I have entered the following into Visual Studio Code and it seemed to look OK:
function suggestZipCodes() {
// defined possible ZipCode
ZipCodes = [
{ name: '94102' },
{ name: '94103' },
{ name: '94104' },
{ name: '94105' },
{ name: '94107' },
{ name: '94108' }];
var OnZipCodekeyPress = function (fld) {
var ZipCodetxt = Xrm.Page.getControl("address1_postalcode").getValue();
resultSet = {
results: new Array(),
commands: {
id: "ZipCodecmd",
label: "Search in Bing",
action: function () {
window.open(" http:// bing.com");
// Open Bing URL
} } };
var ZipCodetxtLowerCase = ZipCodetxt.toLowerCase();
for (i = 0; i < ZipCodes.length; i + +) {
if (ZipCodetxtLowerCase === ZipCodes[i]. name.substring(0, ZipCodetxtLowerCase.length).toLowerCase()) {
resultSet.results.push({
id: i,
fields: [ZipCodes[ i]. name]
});
}
if (resultSet.results.length >= 10) {
break;} }
if (resultSet.results.length > 0) {
fld.getEventSource().showAutoComplete( resultSet);// Show Auto Complete
}
else {
fld.getEventSource().hideAutoComplete();
// Hide Auto Complete
}
}; Xrm.Page.getControl("address1_postalcode").addOnKeyPress(OnZipCodekeyPress);
}
However, when i create that as a web resource, and add that to the form, I get a similar error to before:
Web resource method does not exist: suggestZipCodes
Session Id: 646fc911-3b68-4864-9fb4-9178c192fbeb
Correlation Id: b3d1e55c-66ac-41c9-ab17-25146f76c58f
Time: Tue Dec 24 2019 12:02:57 GMT+0000 (Greenwich Mean Time)
Log:
ReferenceError: Web resource method does not exist: suggestZipCodes
at jp.execute (ghdunn1.crm11.dynamics.com/.../app.js
at Ap._executeIndividualEvent (ghdunn1.crm11.dynamics.com/.../app.js
at Ap._executeEventHandler (ghdunn1.crm11.dynamics.com/.../app.js
at Object.execute (ghdunn1.crm11.dynamics.com/.../app.js
at v._executeSyncAction (ghdunn1.crm11.dynamics.com/.../app.js
at v._executeSync (ghdunn1.crm11.dynamics.com/.../app.js
at v.executeAction (ghdunn1.crm11.dynamics.com/.../app.js
at t.dispatch (ghdunn1.crm11.dynamics.com/.../app.js
at Object.dispatch (ghdunn1.crm11.dynamics.com/.../app.js
at Object.dispatch (ghdunn1.crm11.dynamics.com/.../app.js
Any clues?