I have a WebAPI JS error on Quote Entity. It is only occurred in the new Outlook App interface v9.0.x. (see photo)
I know it's an error of my JS code, but it works well on the CRM side (both for classic interface and new UUI).
export namespace Form { // GLOBAL VARIABLES var formContext; export function onFormLoad(executionContext) { formContext = executionContext.getFormContext(); if (Grifal.Global.isNewRecord(formContext)) { defaultValues(); } // filtering anyway without account change event: filterAddressDestLookup(); // handler function addOnChange() events: addOnChanges(); // on load event it insert the last address saved: insertAccountAddress(); // on load event it insert the last destination address saved: insertDestinationAddress(); } function defaultValues() { formContext.getAttribute("effectivefrom").setValue(new Date()); } function addOnChanges() { formContext.getAttribute("customerid").addOnChange(insertAccountAddress); formContext.getAttribute("customerid").addOnChange(function(){ deleteDestinationAddress(); }); formContext.getAttribute("customerid").addOnChange(function () { //performs cleanup of the lookup just changes the potential customer(cliente) formContext.getAttribute("disc_indirizzodestinazioneid").setValue(null); filterAddressDestLookup(); }); formContext.getAttribute("disc_indirizzodestinazioneid").addOnChange(insertDestinationAddress); } function filterAddressDestLookup() { //start the dropdown filter on lookup at the click on the search icon(lente) formContext.getControl("disc_indirizzodestinazioneid").addPreSearch(function () { filterLookup(); }); } function insertAccountAddress() { var accountLookup = formContext.getAttribute("customerid").getValue(); // if entity is: null, empty or a contact => no set bills destination if (accountLookup == null || accountLookup.length == 0 || accountLookup[0].entityType == "contact") { deleteAccountAddress(); deleteDestinationAddress(); return; } Sdk.WebAPI.retrieveRecord( accountLookup[0].id, "accounts", "address1_line1,address1_line2,address1_line3,address1_city,address1_stateorprovince,address1_postalcode,address1_country", "", function (account) { formContext.getAttribute("billto_line1").setValue(account.address1_line1); formContext.getAttribute("billto_line2").setValue(account.address1_line2); formContext.getAttribute("billto_line3").setValue(account.address1_line3); formContext.getAttribute("billto_city").setValue(account.address1_city); formContext.getAttribute("billto_stateorprovince").setValue(account.address1_stateorprovince); formContext.getAttribute("billto_postalcode").setValue(account.address1_postalcode); formContext.getAttribute("billto_country").setValue(account.address1_country); }, errorHandler); } function insertDestinationAddress() { // populated destination address details var destAddressLookup = formContext.getAttribute("disc_indirizzodestinazioneid").getValue(); if (destAddressLookup == null || destAddressLookup.length == 0) { deleteDestinationAddress(); return; } Sdk.WebAPI.retrieveRecord( destAddressLookup[0].id, "disc_indirizzodidestinaziones", "disc_via1,disc_via2,disc_via3,disc_citta,disc_cap,disc_provincia,disc_regione,disc_paese", "", function (address) { formContext.getAttribute("shipto_line1").setValue(address.disc_via1); formContext.getAttribute("shipto_line2").setValue(address.disc_via2); formContext.getAttribute("shipto_line3").setValue(address.disc_via3); formContext.getAttribute("shipto_city").setValue(address.disc_citta); formContext.getAttribute("shipto_stateorprovince").setValue(address.disc_provincia); formContext.getAttribute("shipto_postalcode").setValue(address.disc_cap); if (address.disc_regione == null || address.disc_regione == "") { formContext.getAttribute("shipto_country").setValue(address.disc_paese); } else { formContext.getAttribute("shipto_country").setValue(address.disc_paese + " (" + address.disc_regione + ")"); } }, errorHandler ); } function filterLookup() { var account = formContext.getAttribute("customerid").getValue(); // if entity is: null, empty or a contact => no filter activtiy if (account == null || account.length == 0 || account[0].entityType == "contact") { return; } // for filter added a row condition into query fetchXML var fetchXml = "<filter type='and'><condition attribute='disc_accountid' operator='eq' uiname='" + account[0].name + "' uitype='" + account[0].entityType + "' value='" + account[0].id + "' /></filter>"; formContext.getControl("disc_indirizzodestinazioneid").addCustomFilter(fetchXml, "disc_indirizzodidestinazione"); } function deleteAccountAddress() { formContext.getAttribute("billto_line1").setValue(null); formContext.getAttribute("billto_line2").setValue(null); formContext.getAttribute("billto_line3").setValue(null); formContext.getAttribute("billto_city").setValue(null); formContext.getAttribute("billto_stateorprovince").setValue(null); formContext.getAttribute("billto_postalcode").setValue(null); formContext.getAttribute("billto_country").setValue(null); formContext.getAttribute("billto_composite").setValue(null); } function deleteDestinationAddress() { formContext.getAttribute("shipto_line1").setValue(null); formContext.getAttribute("shipto_line2").setValue(null); formContext.getAttribute("shipto_line3").setValue(null); formContext.getAttribute("shipto_city").setValue(null); formContext.getAttribute("shipto_stateorprovince").setValue(null); formContext.getAttribute("shipto_postalcode").setValue(null); formContext.getAttribute("shipto_country").setValue(null); formContext.getAttribute("shipto_composite").setValue(null); } function errorHandler(error: Error) { var alertStrings = { text: "Si è verificato un errore.\n\nError: " + error.message }; Xrm.Navigation.openAlertDialog(alertStrings); } }
So it seems like an error that only happens with Outlook. The error always occurs only in Outlook even if I'm a system administrator.
How can I debug to resolve this error?
On the internet the old documentation is not clear and does not solve the problem for the new D365 version 9.0.x ...
The code, onChange the potential customer, must provide its possible "Indirizzo di Destinazione" (Destiantion Addresses: 1 Account related to N "IndirizzoDestiznazione" Entity) and the default address into the Account. The WebAPI library isn't the official MS library but is valid for the current CRM version.