Simple API example – walk-through

This simple example will popup a window that displays the DT events as they happen. It works in conjunction with a phonecall form.

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:

simple_api_new_ws

 

3. Add the above javascript library, and the core DT javascript library to the phonecall form, per this snap:

simple_api_form_libraries

 

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.

simple_api_dt_events_page