Quickstart: Creating Custom Screen Pops Using Visualforce

This was originally part of Developing with the Service Cloud.

Warning About This Page

IMPORTANT: CTI Toolkit, also known as the Desktop CTI, is retired. The CTI Toolkit is no longer supported, and adapters built on the CTI Toolkit don’t work. To continue using CTI functionality, migrate to Salesforce Open CTI. Work with your CTI vendor or partner to create an Open CTI implementation. See the Open CTI Developer Guide.

Use Case

The time that agents spend clicking through Service & Support is often scrutinized closely. Companies want to enable their agents to be as productive as possible, so if there's a way that few clicks and a few seconds can be saved, it's usually worth investigating. With the release of Spring '10 and CTI Toolkit 2.0, customers can now configure their CTI adapters to pop to a custom Visualforce page to enable the agent to be directed to the right page quickly.

See the blog post corresponding to this quick start for more information and pretty pictures.

Background

Note that this code will only work with CTI adapters developed on the CTI Toolkit 2.0 and later. To find out which CTI Toolkit your adapter was built with, run the adapter, right-click the S-phone icon in the system tray, and click About... The Call Center Edition version corresponds to the CTI Toolkit version.

If you are running an adapter built on an earlier version of the CTI Toolkit, you may want to ask your vendor if they offer a newer version.

To configure your adapter to pop to a Visualforce page, modify the Softphone Layout at Setup | Customize | Call Centers | Softphone Layouts.

Sample Code:

This sample Visualforce page accepts the information that CTI provides on the querystring of the URL and generates a page that searches for Contacts and Accounts. Admittedly, this is not a terribly useful page to pop, particularly since you can also pop a standard search screen that does the same thing, but it does serve to demonstrate how you might use the information provided by the CTI adapter to pop information that is relevant to your agents.

Visualforce page:

<apex:page controller="SearchPageController">
   <apex:pageBlock title="Contacts">
      <apex:pageBlockTable value="{!contacts}" var="contact">
         <apex:column headertitle="Name"><a href="/{!contact.Id}"><apex:outputText value="{!contact.Name}" /></a>
         </apex:column>
         <apex:column value="{!contact.MailingCity}"/>
         <apex:column value="{!contact.Phone}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
   <apex:pageBlock title="Accounts">
      <apex:pageBlockTable value="{!accounts}" var="account">
         <apex:column headertitle="Name"><a href="/{!account.Id}"><apex:outputText value="{!account.Name}" /></a>
         </apex:column>
         <apex:column value="{!account.BillingCity}"/>
         <apex:column value="{!account.Phone}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
</apex:page>

Controller:

public class SearchPageController {
    public List<Account> accounts {get; private set;}
    public List<Contact> contacts {get; private set;}

    public SearchPageController() {
        String callerId = ApexPages.currentPage().getParameters().get('ANI');
        List<List<SObject>> searchList = [FIND :callerId IN PHONE FIELDS RETURNING Account(Id, Name,BillingCity,Phone), Contact(Id, Name,MailingCity,Phone)];

        if (searchList!=null) {
            accounts = ((List<Account>)searchList[0]);
            contacts = ((List<Contact>) searchList[1]);
        }
    }
}