Pages

Thursday, April 2, 2015

Debugging Dynamics CRM for Outlook

I had a recent adventure with a Kendo UI project that took me into the recesses of a place I have very skillfully avoided for 7 lucky years: debugging JavaScript in the CRM for Outlook client.  The problem jumped out at me at the worst possible moment: Go Live.  Apparently the testers hadn’t thought to use the Outlook client, even though a majority of users would.  I number myself among them.

This lead me to discover a quaint little bug in the CRM for Outlook client: when you use JQuery to attach to multiple mouse events (“mousedown”, “mouseup”, and “click”) in an HTML Web Resource, only the first one in the event sequence gets its handlers fired.  The rest of the sequence does not complete.

“Wait, what?”  That’s what I said, too.  I’m going to recount the tale here, in case anyone else runs into this bug, but I will return to the process of debugging JavaScript in Outlook.

So, it works like this: when you click on a mouse button, there are 3 distinct events sent through the browser’s runtime, in order:

  1. mousedown  “The button is pressed down.”
  2. mouseup  “The button has been released.”
  3. click  “The button was pressed and released.”

The way this bug manifests, is when more than one of those events is being watched—at least by jQuery, anyway.  (I haven’t taken the time to see if browser-native event handlers are not affected in this way.)  By attaching a handler to both the “mousedown” and “click” events, we expect that a click will trigger that handler twice. 

It does; in every other browser, but not within the Outlook client.  This is actually incredibly easy to test:

<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#clickable").on("mousedown", function() { alert("Mouse is down.");});
$("#clickable").on("mouseup", function() { alert("Mouse is up.");});
$("#clickable").on("click", function() { alert("Mouse was clicked.");});
});
</script>
</head>
<body>
<span id="clickable">Click on me to see the event pipeline.</span>
</body>
</html>

This means that developers may need to find creative solutions to enable or support richer HTML interfaces from within Outlook.  Thankfully, the client-side context has a helpful getClient() method.

With that behind us…

So, the process of debugging Dynamics CRM for Outlook hasn’t changed the whole time I’ve been avoiding it, and the process is actually very simple: you debug with Visual Studio.

First, allow Visual Studio to do the dirty work by deselecting “Disable script debugging (Other)” from the Outlook machine’s Internet Options.

image

Then, launch Outlook and Visual Studio.  Do not attach to Outlook’s main process.  Find the page you want to debug, and attach Visual Studio to the instance of Microsoft.Crm.Application.Outlook.WebFormsHost.exe matching the page you’re viewing.  Each new window gets its own host process, so look carefully.

image_thumb[50]

After that, you should be able to summon the debugger with a simple “debugger;” statement.  What you’ll probably miss most, like I did, is a nice JavaScript console, and a DOM Explorer, like those found in the debugging tools of most browsers.

Then, when you make changes to your HTML or JavaScript, you’ll run into CRM for Outlook’s quirky, bi-layered cache.  The steps to clear the cache are as follows:

  1. Launch Internet Options from the Control Panel.  You cannot rely on the Internet Options launched from Internet Explorer’s menu—it doesn’t reach into the client’s cache, which I speculate is maintained in a phantom profile.
  2. Delete browsing history:
    image
  3. Launch the Diagnostics utility, which was installed with the CRM for Outlook connector.  It can be found in the Start Menu.  Repair your installation if you cannot find it.
  4. Under “Advanced Troubleshooting”, click to “Delete Temporary Microsoft Dynamics CRM Client Files”.
    image

For JavaScript changes, this is enough—simply hit F5 and the page will reload with your changes.  For HTML resources, you will first need to close all CRM windows displaying the page, and then use the process above.

That’s really all there is to it.  I decided to write it all up here, because this information wasn’t easy to come by, and involved some trial and error.  Hope it helps!

Tuesday, August 26, 2014

A CRM Book and eXtremeCRM

I’ve undergone a change of employers, for both personal and professional reasons, but hope that will serve as a catalyst to reconnect with the Dynamics CRM community—with whom I’ve grown too distant for comfort.  Though I’m never more than a stone’s throw from you all, I feel that the lack of regular communication from me has alienated my audience.  While I’ve been growing and learning, I’ve been amassing a collection of knowledge and experience that I want to pass along—and I’d like to commit to doing so through this blog.

However, while all these cards are coming together in the next few weeks, I’ll simply offer some filler.  For those who follow me on twitter, news of a new book with my name on it is currently on the shelves.  The CRM 2013 Quickstart guide is a new work, intended for the intermediate and advanced Dynamics CRM users.  In particular, my contribution is the chapter “Developers, Developers, Developers” at the end.

The material in this book is up-to-date, and is an experienced look into the important differences between CRM 2013 and previous versions.  The digital version is available both on Amazon and through our publisher’s site:  http://www.crm2013quickstart.com/Buy/Discount

Finally, I’ll be attending eXtremeCRM in Las Vegas, Oct. 5th – 8th.  I’m not pegged for any presentations, but I’ll be attending roundtables where I’m welcome.  What I’m looking forward to, is the Innovation Challenge on the Sunday prior to the event.  Last year, I built a tool called “RedHanded” which was a light-weight, use-tracking feature, wholly contained inside CRM.  This year, I’m planning to build… oh, well, I guess you’ll have to be there to find out.  :)

Thursday, February 6, 2014

I’m not dead yet!

It’s about time that I come to you, the Dynamics CRM Community, you rich and vibrant thing, with an apology and an explanation for my relative absence over these bitter winter months.  Rest assured that I’m not dead.  (And if that assures your unrest, then I can’t help you.)

It has been ages, it seems, since I answered a forum post, and longer still since I published a blog post of technical merit.  As such, I felt that I should at least fill what scarce readers I may still have (those devoted, loyal few) with some hope and information about what I’m working on for them.

Firstly, and most looming, I will be at Convergence 2014 in Atlanta.  Not simply as an attendee, mind you, but as a co-presenter with the indomitable George Doubinski.  Together, we’ll present “heroic” development topics under the CRMUG banner, and hope to see many of you there!

Secondly, an unnamed book project should also be published this year, with my name found upon it.  The details of this are intentionally vague at this point, as I’m still uncertain what more I can say about this work.  However, I am honored to be involved, and hope I can deliver compelling and useful content for other Dynamics CRM developers.

Lastly, I’ve been working tirelessly for my employer, Avtex, and have taken extra effort to identify and isolate many functional components that we can release as free community offerings.  Obviously the intent is to stoke the fires of interest around Avtex in the Dynamics CRM space, but also to introduce the community to our “Avtex 360” concept: that to provide a better experience for our clients’ modern customers, we apply experienced and tech-savvy consultants and implementers across all points of interaction, and optimize those points with robust and tight integration between platforms and processes.  Dynamics CRM is but one pillar of that mission, yet with strong engagement and recognition in several industry venues (and a varied and recognizable client portfolio), Avtex is not only a clear leader, but possibly the best kept secret in the field of Customer Experience (CX).

So, that’s where I’ve been and what I’ve been up to.  However, as a Microsoft MVP, I’m continually looking for ways to squeeze in events and community face-time, so I’d like to also mention some up-coming events in which I’ll be participating in the coming weeks:

I’m also trying to back-fill some content that supplements a webinar I gave last year on xRMVC, which I did for CRM Partner Connections (CRMPC), an offshoot of CRMUG.  That probably won’t see the light of day until April or May, but we’ll see. 

So, in closing, I’m not dead yet, and I hope to see you soon!