I have been repeatedly asked a question about Unified Service Desk (USD) for Microsoft Dynamics CRM, how do we stop the often annoying “webpage you are viewing is trying to close the window” dialog?
In this post I will show you a couple of approaches I have used to solve this problem.
By way of an example I will use a phone call. You can see below that I have started a session containing an inbound phone call. Out of the box if the user clicks “Mark Complete” they will see the annoying dialog.
Below you can see that Internet Explorer has detected that the window is trying to close and this has created an unwanted prompt in Unified Service Desk. You may think seeing this isn’t much of a problem but think again. USD is aimed at contact centre operators, someone in that environment could easily take or make 300 phone calls per day. After clicking “Yes” a few hundred times you may find the operators will start to form a dislike of the developer who provided that feature. J
I have two possible approaches to solving this problem. This first is to simply allow the window to close but to prevent the popup.
The second is allow the phone call to be marked as complete but to leave the tab open. (I will explain this option and why you might want to do this in a second.)
- Option One – Prevent Dialog
- Option Two – Prevent Dialog (Keeping tab open)
Note: You can find an updated version of option one here.
Option One – Prevent the Dialog.
The steps for option one include ….
- Create a RunScript Action.
- Add the action to BrowserDocumentComplete Event.
Step One – Create a RunScript Action.
You can use a RunScript action to substitute the normal close window function with one that will close the tab “nicely” in USD. The function will need to look like this;
function closeWindow(focus) {
window.open("http://close/");
}
My action call for phone call looked like the one below;
Step Two – Add the action to BrowserDocumentComplete Event.
I then simply added this to the “BrowserDocumentComplete” event of my phone call hosted control. As shown below.
Now when you run USD clicking Mark Complete on the phone call will simply complete the phone call and close the tab. Without the annoying dialog.
Option Two – Prevent the Dialog (Keeping tab open).
I have demonstrated how to prevent the dialog, so we are done. Right? Yes and no ….. as sometimes you may need a slightly different approach.
If I start a session for a contact, then phone a phone call in a second tab allowing the user to close that tab is perfectly acceptable. But if I start the session with the phone call as the first tab if the user closes that tab they are left with a session open that contains nothing. And we have another annoyance for the user.
In this circumstance you will want the user to be able to click “MARK COMPLETE” but the tab remain open. Leaving the tab open is easy but the screen won’t have refreshed. Meaning the now completed (read-only) phone call will still appear to be editable. Here is how I solved that challenge ….. the steps involved are;
- Create a RunScript Action.
- Add RunScript to BrowserDocumentComplete Event.
- Create a Refresh Action.
- Create an ExecuteOnTimeout Action.
- Add ExecuteOnTimeout Action to Saved Event.
Step One – Create a RunScript Action.
Firstly I created a RunScript action as before. But this time the function actually did nothing. Meaning the close didn’t happen.
function closeWindow(focus) {
// ** THERE IS NOTHING IN HERE!
}
Step Two – Add RunScript to BrowserDocumentComplete Event.
And I added this action call to the BrowserDocumentComplete event on phone call as before.
Step Three – Create a Refresh Action.
Next I need to refresh the phone call tab after it is saved, so I created an action to refresh the phone call page if it had been completed. This is simple enough the hosted control was “Phonecall” and the action was “Refresh”. Notice I also added a condition to the action of “[[phonecall.statecode]]”==Completed
I did this as I only wanted the phone call tab to be refreshed if the phone call had actually been marked as completed.
Step Four – Create an ExecuteOnTimeout Action.
Next I needed to consider when / how to trigger this action. The problem is you can simply add it to the “Saved” event on phone call. But just doing that can trigger yet another different annoying dialog!
To avoid this dialog, we need to ensure the phone call save has completed before we refresh the page. To achieve that I created another action. The timeout action looked like the one below. My hosted control this time was my global manager and the action was “ExecuteOnTimeout”. In the data field I entered “milliseconds=500”, this was going to add a ½ second delay. Now I didn’t want this delay randomly for no reason so I also added the same condition as before. “[[phonecall.statecode]]”==Completed
Having saved my ExecuteOnTimeout action I added the refresh action as a sub action. You will find the sub action calls option in the navigation bar of your “ExecuteOnTimeout” action.
My sub actions eventually looked like this;
Step Five – Add ExecuteOnTimeout Action to Saved Event.
One final step remained to add the ExecuteOnTimeout action to the “Saved” event on phone call. Meaning after a phone call was saved as completed after a ½ second pause the phone call tab will be refreshed. The operator will then be looking at the completed read-only phone call as required. Simples!
I hope you can see this is actually quite a simple thing to achieve.
J
Leave a comment