DocumentComplete event triggering multiple times in Web Hosted Application.

Apr 11, 2013 at 2:15 PM
While working on to resolve Popup blocker issue on CCA with CRM Rollup 12 installed on server I came accross a strange behaviour of CCA/UII. We have a webapplicationadapter from where we are attaching eventhandler on DocumentComplete event on the Web Hosted Application , normally DocumentComplete event fires when a document is completely loaded and initialized hence it should be occuring only once. But in our case whenever we click on a record from the Case Entity homepage grid the DocumentComplete event is getting triggered. If anyone has ever encountered the same issue and knows its cause please do let me know.

Thanks in advance , any help is much appreciated.

Mukul
Apr 12, 2013 at 3:33 PM
I had done some similar exploration on this topic/issue as well trying to tie code into the DocumentComplete event in a web adapter. With the way CRM is laid out, it is actually loading multiple documents.

Doc #1: Main CRM Entity Window (Ribbon and Window Outline)
Doc #2: The CRM Form/Fields/Left-Nav is actually in an IFRAME, so that document get's loaded and triggers document complete
Doc #3: If you have the Notes Entity enabled and visible on the screen, that is another page/IFRAME, so it triggers DocumentComplete again
Doc #4: Once all of the above IFRAMES/Windows have loaded I usually caught 1 more Doc Complete Event

What I had to do, and it works for the most part is track the URL that I'm expecting to open or should be opening. Then when the Document Complete event fires, I analyze the URL to see if it matches the URL I was expecting to open. If it matches, then I'm able trigger a SendAction event to have CCA do something.

At least, that's what worked for me with this scenario, whether it's right or wrong.

Jeremy