Agile Xrm

A blog about all things Dynamics CRM and Agile

Writing a custom screen pop control in Unified service desk for Chat/Telephony scenarios

I have recently been working on putting in a chat component to our CRM deployment and we had decided to use USD to facilitate the agent availability, screen pops and chat sessions.

It took us a little while to get our heads around how to actually make things work happen in USD the way we wanted to. The SDK isn't 100% clear on how your should actually be doing things and there is a bit of a new USD approaches vs Legacy CCA approaches with looking to the community for guidance.

I was lucky enough to spend an hour on a skype call with @jaymepechan who guided us on how we should do things and I had a few AH HA! and light bulb moments on that call!.

I thought I would blog about the things I learnt so that other's could get going a bit quicker than we did.

The first thing Jayme helped with was assisting with how to make call a Windows Navigation rule to pop our Client record when there was a new incoming chat. We had this working, however we used a legacy CCA approach which would become very problematic in terms of performance. We knew beforehand that we needed it work work similarly to the generic listener for CTI, but it was unclear as to how we should go about this. There is currently no SDK documentation on this so we had to use .Net Reflector to look at the generic listener's code and go from there. 

We first need to setup our Windows navigation rule as per below. (In order to do this, you need to make your hosted control a CTI Global Manager Type - an important thing to note here is that it does not need to actually be written as a USD CTI connector for this to work, any USD Custom hosted control will work)

Below is a code snippet that our chat control is using to get the windows navigation rule to fire.

string ani = string.Empty;
string dins = string.Empty;
string callType = string.Empty;
List<LookupRequestItem> collection = new List<LookupRequestItem>();
collection.Add(new LookupRequestItem("customerNumber", 12345));
CtiLookupRequest serializeObject = new CtiLookupRequest(Guid.NewGuid(), base.ApplicationName, callType, ani, dins);
base.FireRequestAction(new RequestActionEventArgs("*", CtiLookupRequest.CTILOOKUPACTIONNAME, GeneralFunctions.Serialize<CtiLookupRequest>(serializeObject)));
The highlighted line is where we pass our custom customerNumber variable to the windows navigation rule search we setup in CRM.
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="contact">
    <attribute name="fullname" />
    <attribute name="parentcustomerid" />
    <attribute name="telephone1" />
    <attribute name="emailaddress1" />
    <attribute name="contactid" />
    <order attribute="fullname" descending="false" />
    <filter type="and">
      <condition attribute="customernumber" operator="eq" value="[[cti.customerNumber]]" />
When this now get's fired by your code in your hosted control, a ScreenPopRequest will be fired in USD which will call the search specified in the windows navigation rule, all your actions and settings to create a new session are then done in the CRM configuration and not in the code as we had initially thought.
We can then access our customerNumber variable in our chat control using the cti.customerNumber variable that get's created in the session for us. No need for any code to live in the NotifyContextChange or any manual manipulation of the variables or sessions in code :)

There is another great set of posts for how to configure the rest here:

Hope this helps someone else our there and thanks again to Jayme for the help.