CTI Pop-up search Custom Page

This is sample page how we can build custom visualforce page for CTI to find matching contacts or accounts for inbound call.

Page:

<apex:page controller="SearchPageController">
   <apex:pageBlock title="Contacts:({!Ccount})">
      <apex:pageBlockTable value="{!contacts}" var="contact">
         <apex:column headerValue="Name"><a href="/{!contact.Id}"><apex:outputText value="{!contact.Name}" /></a>
         </apex:column>
         <apex:column value="{!contact.MailingCity}"/>
         <apex:column value="{!contact.Phone}"/>
         <apex:column value="{!contact.Email}"/>
         <apex:column value="{!contact.Level__c}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
   <apex:pageBlock title="Accounts:({!Acount})">
      <apex:pageBlockTable value="{!accounts}" var="account">
         <apex:column headerValue="Name"><a href="/{!account.Id}"><apex:outputText value="{!account.Name}" /></a>
         </apex:column>
         <apex:column value="{!account.BillingCity}"/>
         <apex:column value="{!account.Phone}"/>
         <apex:column value="{!account.Website}"/>
         <apex:column value="{!account.Type}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
</apex:page>

Apex:

public class SearchPageController {
    public List<Account> accounts {get; private set;}
    public List<Contact> contacts {get; private set;}
    public integer Ccount {get;set;}
    public integer Acount {get;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,Website,Type), Contact(Id, Name,MailingCity,Phone,Email,Level__c)];

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

Post a Comment

0 Comments