Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
Answered

How can I debug the new Dynamics 365 App for Outlook version 9.0.x?

Posted on by 100

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.

OutlookD365Error.jpg

  • Suggested answer
    David Pezzoli Profile Picture
    David Pezzoli 100 on at
    RE: How can I debug the new Dynamics 365 App for Outlook version 9.0.x?

    Ok, I think is a system authentication error with Outlook Desktop Client. Maybe the latest Office update could resolve the error...I Hope...

  • Verified answer
    Ben Thompson Profile Picture
    Ben Thompson 6,350 on at
    RE: How can I debug the new Dynamics 365 App for Outlook version 9.0.x?

    You can't which is why I said to test it in IE which you have already done via your outlook web test above - interestingly the other post got a 401 error with IE and the outlook web app (OWA) so I'm not sure why things are different here...

    Given that I found another link that is unanswered with the same problem I think you will need to raise a support request with Microsoft although I suspect they won't have a better answer than mine....

  • David Pezzoli Profile Picture
    David Pezzoli 100 on at
    RE: How can I debug the new Dynamics 365 App for Outlook version 9.0.x?

    Sorry, but then how do I attach IE debugger to Outlook client?

  • Suggested answer
    Ben Thompson Profile Picture
    Ben Thompson 6,350 on at
    RE: How can I debug the new Dynamics 365 App for Outlook version 9.0.x?

    I will repeat the first bit of my statement above. The Outlook App (when running in the outlook desktop client) uses a hosted IE Process to render and display the Dynamics 365 forms...

  • David Pezzoli Profile Picture
    David Pezzoli 100 on at
    RE: How can I debug the new Dynamics 365 App for Outlook version 9.0.x?

    Thanks for the answer, but this error occurred on my Outlook client side 2016 MSO (16.0.4639.1000). While on Outlook Web (both IE and Chrome) the error  doesn't occur... debugging does not report strange errors...

  • Suggested answer
    Ben Thompson Profile Picture
    Ben Thompson 6,350 on at
    RE: How can I debug the new Dynamics 365 App for Outlook version 9.0.x?

    The outlook app uses IE so you could test things there. The issue doesn't actually seem to be in your Javascript - it's a 401 unauthorised error which is coming from the server via the webapi call...

    The issue is also reported at community.dynamics.com/.../282217 and I remember a couple of other posts around here with a similar issue where external calls are failing but I can't find any with an answer..

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans