This simple example will popup a window that displays the DT events as they happen. It works in conjunction with a phonecall form.
IMPORTANT: You MUST call RegisterForEvents() first, to be able to use any of the Dynamics Telephony functions, and get the events.
1. Make a file with Notepad called dt_SimpleEG.js and paste in the following code:
var wndEvents = null; // A variable to hold the popup window reference. var fnDTEventHandler = function (ev) { //Our DynamicsTelephony Event Handler. try { if (wndEvents == null) { //first time per call, wndEvents will be null, and the popup window will need to be re-created wndEvents = window.open('', 'dtEventsWindow', 'menubar=1,resizable=1,status=1,width=750,height=250'); wndEvents.document.body.innerHTML = '<h1>Dynamics Telephony Events</h1>'; } // add this event to the list... wndEvents.document.body.innerHTML += '<div>' + ev.dtEventArgs.toString() + '</div>'; } catch (e) { } }; // Register for Events with DynamicsTelephony using our Handler 'fnDTEventHandler'. DynamicsTelephony.RegisterForEvents(fnDTEventHandler);
2. Go to CRM > Settings > Customizations > Customize the system and add the above file as a Webresource, per this snap:
3. Add the above javascript library, and the core DT javascript library to the phonecall form, per this snap:
4. Publish all customizations
5. Run DT and do a click-to-dial or take an inbound call or an outbound campaigncall. NOTE these need to be configured to pop the phonecall form for the javascript to run.