+ Start a Discussion
DJP1SDJP1S 

Disabling an inputField via JavaScript based on SelectList choice?

I've got a big spreadsheet-style input. in a pageBlock. I''ve tried making an asynchronous call to my controller and rerendering the page based on the field value, but this is painfully slow. I'd like to use JavaScript to disable/enable an inputField on a row once a selectList is chosen. Here's what I've got, and I can see that it's not throwing any errors in Chrome and referencing the correct value. Still, it does nothing! Any help?

 

Specifically, I need help passing the selected value from the selectlist "myList" to the JavaScript in the inpuField "value" and getting it to actually disable based on that argument.

 

<apex:pageBlockSection id="Calls" columns="1" collapsible="true" title="Calls" rendered="{!totalCalls > 0}">           
            
    <apex:outputPanel styleClass="tableContainer" layout="block">
    <apex:pageBlockTable id="resultsIMC" value="{!calls}" var="n" cellPadding="4" border="1" styleclass="floatingHeaderTable">
              <apex:column value="{!n.Client_Call_Time__c}" headerValue="Call Time">
              </apex:column>
              <apex:column value="{!n.Nice_CallerID__c}" headerValue="Caller ID">
              </apex:column>
              <apex:column value="{!n.Duration__c}" headerValue="Duration">
              </apex:column>
              <apex:column headerValue="Disposition">
              <apex:selectList id="myList" value="{!n.Disposition__c}" multiselect="false" size="1" onChange="disableValue(this.value);">
                    <apex:selectOptions id="disposition" value="{!availablePick}" >
                    </apex:selectOptions>
              </apex:selectList>
              </apex:column>
              <apex:column headerValue="Category">
              <apex:selectList id="myCatCall" value="{!n.Category__c}" disabled="{!IF(n.Disposition__c != 'Accept',  true, false)}" multiselect="false" size="1" >
                    <apex:actionSupport event="onchange" action="{!updateCall}" rerender="parameters">
                        <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/>
                    </apex:actionSupport>
                    <apex:selectOptions value="{!availableCat}"/>
              </apex:selectList>
              </apex:column>
              <apex:column headerValue="Value" style="width:20px">
              <apex:inputField id="value" value="{!n.Value__c}">
               <apex:actionSupport event="onchange"  action="{!updateCall}" rerender="parameters">
                        <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/>
                    </apex:actionSupport>
                       <script>
                       function disableValue(e) { 
                            if ( e == "Reject" ) {
                               document.getElementById('{!$Component.value}').setAttribute("disabled","disabled");
                            } else {
                               document.getElementById('{!$Component.value}').removeAttribute("disabled");
                            }
                        }
                       </script>
              </apex:inputField>
              </apex:column>        
            </apex:pageBlockTable>
            </apex:outputPanel>
        </apex:pageBlockSection>

 

Nantha_WipNantha_Wip

Remove <apex:actionsupport from inputfield,

you can get the value from selectlist to javascript by using disableValue(this.value) itself.

 

If you have any specific reason for having the actionsupport then please post your controller code also...will help to find the solution....

 

 

Please mark this as answer if its solve your problem

 

 

DJP1SDJP1S

I tried that, but it doesn't seem to work. 

Nantha_WipNantha_Wip

Can you post your controller and VF code....

DJP1SDJP1S

Here's what I ended up doing. I just removed the JavaScript since it doesn't seem like it'll work for inputFields. The problem is that the disabling occurs whenever the controller state is updated o the server, rather than handled at the page level. It's just slow.

 

Would still love to get the above code working, though.

 

<apex:page Controller="LeadsFormController"  showHeader="true" sidebar="true" docType="html-5.0" action="{!init}" title="Qualify Leads">

   <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
   <script src="{!URLFOR($Resource.jquery_vfFloatingHeaders)}"></script>
   <style type="text/css">
        .lAlign {padding-left:4px;}
        .panelStyle {font-family:arial;
                     font-size:9pt;
                     color:#484848;
                     } 
        .bold {font-weight:bold;}
        .right {text-align:right;}
        .left {text-align:left;}
        .loadStyle {font-weight:bold;color:purple;}
        .updateStyle {color:blue;}
        .tableContainer
        {
            height:300px; 
            width:940px;
            overflow: auto;
        }       
        .floatingStyle 
        { 
            position:relative; 
        }
    </style>  
    <apex:form id="myLeads">
    <script>
    function setFocusOnLoad(){
    
    } 
    </script>
    <apex:pageBlock id="searchBlock">
    <apex:outputPanel id="parameters">
    <b>Leads Back To:</b>&nbsp;<apex:inputText value="{!datename}" size="10" id="demo" onfocus="DatePicker.pickDate(false, this , false);" />  
    <b>Leads Up Until:</b>&nbsp;<apex:inputText value="{!datename2}" size="10" id="demo2" onfocus="DatePicker.pickDate(false, this , false);" />
    <apex:pageMessage rendered="{!isAccountIDError}" summary="{!accountIDError}" severity="info" strength="2" /> &nbsp;&nbsp;<br/>
    <b><apex:outputText id="cc" value="ClientCode:" style="width:110px;font-weight:bold;" rendered="{!IF(runOnClientCode == true, true, false)}"/></b>&nbsp;
    <apex:inputText id="client" value="{!nameString}" style="width:110px" rendered="{!IF(runOnClientCode == true, true, false)}"/>
    <b>Keyword:</b>&nbsp;<apex:inputText id="Keyword" value="{!keyword}" style="width:110px"/>
    
    <apex:commandButton id="search" action="{!getMyLeads}" value="Go" rendered="{!IF(runOnClientCode == false, true, false)}" rerender="myLeads" status="SaveStatus"/>&nbsp;
    <apex:commandButton id="go" action="{!go}" value="Get Leads" rendered="{!IF(runOnClientCode == true, true, false)}" rerender="myLeads" status="SaveStatus"/>&nbsp;
    <apex:commandButton id="save" action="{!updateLeads}" onClick="changeA1();" value="Save" rerender="myLeads" status="SaveStatus"/>&nbsp;
                <apex:actionstatus id="SaveStatus">
                    <apex:facet name="start">
                        <div class="waitingSearchDiv" id="el_loading" style="background-color:#fbfbfb; height:100%; opacity:0.65; width:100%;"> 
                            <div class="waitingHolder" style="top: 84px; width: 91px;">
                                <img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
                                <span class="waitingDescription">Working...</span>
                            </div>
                        </div>
                    </apex:facet>
                </apex:actionstatus>
    </apex:outputPanel>
    </apex:pageBlock>
    <apex:actionFunction name="autosave" action="{!updateLeads}" rerender="parameters" />
    <script>
    $(document).ready(function() {
        $('.floatingHeaderTable').vfFloatingHeaders();
    });
    </script>
    <script>
        var variableA = 'yes';
        function changeA(){
            if(variableA == 'yes') variableA = 'no';
        }
        function changeA1(){
            if(variableA == 'no') variableA = 'yes';
        }
        window.onbeforeunload = function (evt) {
           var message = 'You are about to leave before saving your progress. Please make sure to click "Save" before leaving';
           if (typeof evt != 'no') evt = window.event;
           if (evt) evt.returnValue = message;
           if(variableA == 'no') return message;
        }
    </script>
    <apex:pageBlock id="showLeads">
    <apex:pageBlockSection id="Calls" columns="1" collapsible="true" title="Calls" rendered="{!totalCalls > 0}">    
    <apex:outputPanel styleClass="tableContainer" layout="block">
    <apex:pageBlockTable id="resultsIMC" value="{!calls}" var="n" cellPadding="4" border="1"  >
              <apex:column value="{!n.Client_Call_Time__c}" headerValue="Call Time">
              </apex:column>
              <apex:column value="{!n.Nice_CallerID__c}" headerValue="Caller ID">
              </apex:column>
              <apex:column value="{!n.Duration__c}" headerValue="Duration">
              </apex:column>
              <apex:column headerValue="Disposition">
              <apex:actionRegion immediate="true">
              <apex:selectList id="myList" value="{!n.Disposition__c}" multiselect="false" size="1">
                    <apex:actionSupport event="onchange" action="{!updateCall}" rerender="myLeads">
                        <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/>
                    </apex:actionSupport>
                    <apex:selectOptions id="disposition" value="{!availablePick}" >
                    </apex:selectOptions>
              </apex:selectList>
              </apex:actionRegion>
              </apex:column>
              <apex:column headerValue="Category">
              <apex:actionRegion immediate="true">
              <apex:selectList id="myCatCall" value="{!n.Category__c}" disabled="{!IF(n.Disposition__c == 'Reject' || n.Disposition__c == '<Unknown>', true, false)}" multiselect="false" size="1" >
                    <apex:actionSupport event="onchange" action="{!updateCall}" rerender="parameters">
                        <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/>
                    </apex:actionSupport>
                    <apex:selectOptions value="{!availableCat}"/>
              </apex:selectList>
              </apex:actionRegion>
              </apex:column>
              <apex:column headerValue="Value (Numbers Only)" style="width:20px">
              <apex:actionRegion immediate="true">
              <apex:inputField id="value" value="{!n.Value__c}">
                  <script>document.getElementById('{!$Component.value}').disabled={!IF(n.Disposition__c == 'Reject' || n.Disposition__c == '<Unknown>', true, false)};</script>
                  <apex:actionSupport event="onchange" action="{!updateCall}" rerender="parameters">
                        <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/>
                    </apex:actionSupport>
              </apex:inputField>
              </apex:actionRegion>
              </apex:column>        
            </apex:pageBlockTable>
            </apex:outputPanel>
        </apex:pageBlockSection>
    <apex:pageBlockSection id="Chats" columns="1" collapsible="true" title="Chats"  rendered="{!totalChats > 0}">           
    <apex:outputPanel id="P" layout="block" styleClass="tableContainer">
    <apex:pageBlockTable id="resultsP" value="{!chats}" var="n" cellPadding="4" border="1"  >
              <apex:column value="{!n.Chat_Time__c}" headerValue="Chat Time">
              </apex:column>
              <apex:column value="{!n.First_Name__c}" headerValue="First Name">
              </apex:column>
              <apex:column value="{!n.Last_Name__c}" headerValue="Last Name">
              </apex:column>
              <apex:column value="{!n.Email__c}" headerValue="Email">
              </apex:column>
              <apex:column value="{!n.Phone__c}" headerValue="Phone">
              </apex:column>
              <apex:column headerValue="Disposition">
              <apex:actionRegion immediate="true">
              <apex:selectList id="myList" value="{!n.Disposition__c}" multiselect="false" size="1">
                    <apex:actionSupport event="onchange" onSubmit="changeA();" rerender="myLeads">
                        <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/>
                    </apex:actionSupport>
                    <apex:selectOptions id="disposition" value="{!availablePick}" >
                    </apex:selectOptions>
              </apex:selectList>
              </apex:actionRegion>
              </apex:column>
              <apex:column headerValue="Category">
              <apex:actionRegion immediate="true">
              <apex:selectList id="myCatCall" value="{!n.Category__c}" disabled="{!IF(n.Disposition__c == 'Reject' || n.Disposition__c == '<Unknown>', true, false)}" multiselect="false" size="1" >
                    <apex:actionSupport event="onchange" action="{!updateCall}" rerender="parameters">
                        <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/>
                    </apex:actionSupport>
                    <apex:selectOptions value="{!availableCat}"/>
              </apex:selectList>
              </apex:actionRegion>
              </apex:column>
              <apex:column headerValue="Value (Numbers Only)" style="width:20px">
              <apex:actionRegion immediate="true">
              <apex:inputField id="value" value="{!n.Value__c}">
                  <script>document.getElementById('{!$Component.value}').disabled={!IF(n.Disposition__c == 'Reject' || n.Disposition__c == '<Unknown>', true, false)};</script>
                  <apex:actionSupport event="onchange" action="{!updateCall}" rerender="parameters">
                        <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/>
                    </apex:actionSupport>
              </apex:inputField>
              </apex:actionRegion>
              </apex:column> 
            </apex:pageBlockTable>
            </apex:outputPanel>
        </apex:pageBlockSection>
    <apex:pageBlockSection id="Emails" columns="1" collapsible="true" title="Emails" rendered="{!totalEmails > 0}">           
    <apex:outputPanel id="SI" layout="block" styleClass="tableContainer">
    <apex:pageBlockTable id="results"  value="{!emails}" var="n" cellPadding="4" border="1"  >
              <apex:column value="{!n.Sent_Date_Time__c}" headerValue="Time Sent">
              </apex:column>
              <apex:column value="{!n.Body_First_Name__c}" headerValue="First Name" >
              </apex:column>
              <apex:column value="{!n.Body_Last_Name__c}" headerValue="Last Name">
              </apex:column>
              <apex:column value="{!n.From__c}" headerValue="Email">
              </apex:column>
              <apex:column headerValue="Phone" >
              <apex:outputField value="{!n.Body_Phone__c}"/>
              </apex:column>
              <apex:column headerValue="Disposition">
              <apex:actionRegion immediate="true">
              <apex:selectList id="myList" value="{!n.Disposition__c}" multiselect="false" size="1">
                    <apex:actionSupport event="onchange" onSubmit="changeA();" rerender="myLeads">
                        <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/>
                    </apex:actionSupport>
                    <apex:selectOptions id="disposition" value="{!availablePick}" >
                    </apex:selectOptions>
              </apex:selectList>
              </apex:actionRegion>
              </apex:column>
              <apex:column headerValue="Category">
              <apex:actionRegion immediate="true">
              <apex:selectList id="myCatCall" value="{!n.Category__c}" disabled="{!IF(n.Disposition__c == 'Reject' || n.Disposition__c == '<Unknown>', true, false)}" multiselect="false" size="1" >
                    <apex:actionSupport event="onchange" action="{!updateCall}" rerender="parameters">
                        <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/>
                    </apex:actionSupport>
                    <apex:selectOptions value="{!availableCat}"/>
              </apex:selectList>
              </apex:actionRegion>
              </apex:column>
              <apex:column headerValue="Value (Numbers Only)" style="width:20px">
              <apex:actionRegion immediate="true">
              <apex:inputField id="value" value="{!n.Value__c}">
                  <script>document.getElementById('{!$Component.value}').disabled={!IF(n.Disposition__c == 'Reject' || n.Disposition__c == '<Unknown>', true, false)};</script>
                  <apex:actionSupport event="onchange" action="{!updateCall}" rerender="parameters">
                        <apex:param name="saveThisCall" value="{!n.Id}" assignTo="{!tc}"/>
                    </apex:actionSupport>
              </apex:inputField>
              </apex:actionRegion>
              </apex:column>      
        </apex:pageBlockTable>
        </apex:outputPanel>
    </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

 

DJP1SDJP1S

Controller:

 

public with sharing class LeadsFormController {

    public Client_CC__c[] emails {get;set;}
    public Client_Chat__c[] chats{get;set;}
    public Client_Call__c[] calls{get;set;}
    public String nameString {get;set;}
    public ClientCode__C[] clientCode {get;set;}
    public Integer totalEmails {get; set;}
    public Integer totalChats {get; set;}
    public Integer totalCalls {get; set;}
    public String clientQuery {get;set;}
    public Parameter__c backTo {get;set;}
    public Parameter__c upUntil {get;set;}
    public String AccountId{get;set;}
    public SelectOption[] availablePick {get;set;}
    public SelectOption[] availableCat {get;set;}
    public transient static final String Unknown_OPTN = '<Unknown>';   
    public Boolean callOn {get;set;} 
    public Id tc {get;set;}
    public Map<Id, Client_Call__c> callMap {get;set;}
    public Map<Id, Client_CC__c> CCMap {get;set;}
    public Map<Id, Client_Chat__c> chatMap {get;set;}
    public Boolean runOnClientCode {get;set;}
    public String accountIDError {get;set;}
    public Boolean isAccountIDError {get;set;}
    public String keyword {get;set;}
    public String datename {get;set;}
    public String datename2 {get;set;}
    
    public LeadsFormController(){
        this.availablePick = new List<SelectOption>();
        this.availableCat = new List<SelectOption>();
        this.totalEmails = 0;
        this.totalChats = 0;
        this.totalCalls = 0;
        this.nameString = '';
        this.clientQuery = '';
        this.backTo= new Parameter__c(); 
        this.upUntil = new Parameter__c();
        this.upUntil.DateTime__c = Date.Today();
        this.backTo.DateTime__c = Date.Today().addMonths(-12);    
        this.AccountID = UserUtil.CurrentUser.AccountId__c;
        this.callMap = new Map<Id, Client_Call__c>();
        this.CCMap = new Map<Id, Client_CC__c>();
        this.chatMap = new Map<Id, Client_Chat__c>();
        this.runOnClientCOde = false;
        callOn = true;
        this.accountIDError = 'There is a problem retrieving lead records for your Account. Please notify your IMC and we will have it resolved.';
        this.isAccountIDError = false;
        this.keyword = '';  
        this.datename = string.valueof(Date.today().addMonths(-12).month()) + '/' + string.valueof(Date.today().addMonths(-12).day()) + '/' + string.valueof(Date.today().addMonths(-12).year());    
        this.datename2 = string.valueof(Date.today().month()) + '/' + string.valueof(Date.today().day()) + '/' + string.valueof(Date.today().year());
    }
    
    public PageReference init() {
        String myProfile = UserUtil.CurrentUser.Profile.Name;
        if(this.AccountId != null && myProfile == 'Authenticated Page 1 Website'){
            Account myAccount = [SELECT Id, Name, Industry FROM Account WHERE Id =: this.AccountID LIMIT 1];
            buildPicklistOptions(myAccount.Industry);
            getMyLeads();   
        }if(this.AccountId == null && myProfile != 'Authenticated Page 1 Website'){
            this.runOnClientCode = true;
        }if(this.AccountId == null && myProfile == 'Authenticated Page 1 Website'){
            this.isAccountIdError = true;    
        }
        return null;
    }
    
    public void buildPicklistOptions(String industry) {
        String syndication;
        if(industry != 'Ophthal' && industry != 'CD' && industry != 'Plastics' && industry !='Bariatric'){
            syndication = 'Legal';
        }
        if(industry == 'Ophthal'){
            syndication = 'Ophthal';
        }
        if(industry == 'Plastics'){
            syndication = 'Plastics';
        }
        if(industry == 'CD'){
            syndication = 'CD';
        }
        this.availablePick.add(new SelectOption(Unknown_OPTN, Unknown_OPTN));
        for (Picklist__c pick : [SELECT Id, Name, Active__c
                                FROM Picklist__c 
                                WHERE Active__c = true
                                AND Syndication__c =: syndication
                                AND Picklist_type__c = 'Disposition'
                                ORDER BY Name desc]) {                      
            this.availablePick.add(new SelectOption(pick.name, pick.name));                 
        }
        this.availableCat.add(new SelectOption(Unknown_OPTN, Unknown_OPTN));
        for (Picklist__c pick : [SELECT Id, Name, Active__c
                                FROM Picklist__c 
                                WHERE Active__c = true
                                AND Syndication__c =: syndication
                                AND Picklist_type__c = 'Category'
                                ORDER BY Name desc]) {                      
            this.availableCat.add(new SelectOption(pick.name, pick.name));                 
        } 
    }
    
    public void go(){
        if(this.runOnClientCode == true){
            if(this.clientCode != null){this.clientCode.clear();}
            if(this.calls != null){this.calls.clear();}
            if(this.emails != null){this.emails.clear();}
            if(this.chats != null){this.chats.clear();}
            ClientCode__c myClient = new ClientCode__c();
            this.clientQuery = 'SELECT Id, Name, Account__c FROM ClientCode__c WHERE Name LIKE ' + '\'%' + this.nameString + '%\'' + ' LIMIT 1';
            try{
                myClient = Database.query(this.clientQuery);
            }catch(QueryException e){
                this.accountIDError = 'No matching ClientCodes Found  :-(';
                this.isAccountIDError = true;  
            }
            if(myClient != null){
                this.AccountID = myClient.Account__c;
            }
            if(this.AccountID != null){
                this.clientQuery = 'SELECT Id, Name FROM ClientCode__c WHERE Account__c = ' + '\'' + this.AccountID + '\'';
                try{
                this.clientCode = Database.query(this.clientQuery);
                }catch(QueryException e){}
            }
            if(this.clientCode != null){
            Account myAccount = [SELECT Id, Name, Industry FROM Account WHERE Id =: this.AccountID LIMIT 1];
            buildPicklistOptions(myAccount.Industry);
            getMyLeads();
            }else{
            this.accountIDError = 'No matching ClientCodes Found  :-(';
                this.isAccountIDError = true;  
            }
        }
    }
    
    public void getMyLeads(){
        if(this.isAccountIDError == true){
            this.isAccountIDError = false;
        }
        Date startDate = system.today();
        Date endDate = system.today();
        String myCodes = '';
        try{
            startDate = date.parse(datename);
            endDate = date.parse(datename2);
        }catch(TypeException t){
            this.accountIDError = 'Enter your date in MM/DD/YYY format.';
            this.isAccountIDError = true;
        }
        if(startDate > endDate){
            this.accountIDError = 'You\'re trying to search for dates from future to present. Leads back to should be before leads up until.';
            this.isAccountIDError = true;
        }
        if(this.AccountID != null && this.runOnClientCode == false){
            this.clientQuery = 'SELECT Id, Name FROM ClientCode__c WHERE Account__c = ' + '\'' + this.AccountID + '\'';
            try{
            this.clientCode = Database.query(this.clientQuery);
            }catch(QueryException e){}
        }
        if(this.clientCode.size() > 0){
            Integer i = 0;
            Integer m = this.clientCode.Size();
            for(ClientCode__c cc : this.clientCode){
                if(i==0){
                    myCodes = '(ClientCode__c = ' + '\'' + cc.Id + '\'';
                    i = i + 1;
                }if(i>0 && i < m){
                    myCodes = myCodes + ' OR ClientCode__c = ' + '\'' + cc.Id + '\'';
                    i = i + 1;
                }if(i == m){
                    myCodes = myCodes + ' OR ClientCode__c = ' +'\'' + cc.Id + '\'' + ' )';
                    i = i + 1;
                }
            }
        }
        if(this.keyword == ''){
            system.debug('myCodes: ' + myCodes);
            String emailQuery = 'SELECT Id, Name, From_Email__c,Value__c,Body_First_Name__c,Disposition__c,Category__c,Body_Last_Name__c,Body_Phone__c,From__c,Sent_Date_Time__c FROM Client_CC__c Where ' + myCodes +  ' AND CreatedDate >= :startDate AND CreatedDate <= :endDate LIMIT 50'; 
            this.emails = Database.Query(emailQuery);
            this.totalEmails = this.emails.size();
            String chatQuery = 'SELECT Id, Name,Value__c,Chat_Time__c,First_Name__c,Disposition__c,Category__c,Last_Name__c,Email__c,Phone__c FROM Client_Chat__c Where ' + myCodes + ' AND CreatedDate >= :startDate AND CreatedDate <= :endDate LIMIT 50';
            this.chats = Database.Query(chatQuery);
            this.totalChats = this.chats.size();
            String callQuery = 'SELECT Id, Name, CallerID__c,Value__c,Duration__c,Nice_CallerID__c,Disposition__c,Category__c,Client_Call_Date__c,Client_Call_Time__c FROM Client_Call__c Where ' + myCodes + ' AND CreatedDate >= :startDate AND CreatedDate <= :endDate LIMIT 50';
            this.calls = Database.Query(callQuery);
        }if(this.keyword != ''){
            system.debug('%%%myCodes: ' + myCodes);
            String SOSL = 'FIND ' + '\'' + this.keyword + '*' + '\'' + ' RETURNING Client_CC__c' + ' (' + 'Id,Name, From_Email__c,Value__c,Body_First_Name__c,Disposition__c,Category__c,Body_Last_Name__c,Body_Phone__c,From__c,Sent_Date_Time__c WHERE ' + myCodes +  ' AND CreatedDate >= :startDate AND CreatedDate <= :endDate LIMIT 50' + ')';
            List<List<SObject>> searchList = search.query(SOSL);
            this.emails = ((List<Client_Cc__c>)searchList[0]);
            String SOSLchat = 'FIND ' + '\'' + this.keyword + '*' + '\'' + ' RETURNING Client_Chat__c' + ' (' + 'Id,Name,Value__c,Chat_Time__c,First_Name__c,Disposition__c,Category__c,Last_Name__c,Email__c,Phone__c Where ' + myCodes +  ' AND CreatedDate >= :startDate AND CreatedDate <= :endDate LIMIT 50' + ')';
            List<List<SObject>> searchListChat = search.query(SOSLchat);
            this.chats = ((List<Client_Chat__c>)searchListChat[0]);
            String SOSLcall = 'FIND ' + '\'' + this.keyword + '*' + '\'' + ' RETURNING Client_Call__c' + ' (' + 'Id,Name, CallerID__c,Value__c,Duration__c,Nice_CallerID__c,Disposition__c,Category__c,Client_Call_Date__c,Client_Call_Time__c Where ' + myCodes +  ' AND CreatedDate >= :startDate AND CreatedDate <= :endDate LIMIT 50' + ')';
            List<List<SObject>> searchListCall = search.query(SOSLcall);
            this.calls = ((List<Client_Call__c>)searchListCall[0]);
        }
            for(Client_Call__c ccc : this.calls){
                callmap.put(ccc.Id, ccc);
            }
            this.totalCalls = this.calls.size();
            for(Client_CC__c ccEmail : this.emails){
                ccMap.put(ccEmail.Id, ccEmail );
            }
            this.totalEmails = this.emails.size();
            for(Client_Chat__c cChat : this.chats){
               /* callWrapper callWrap = new callWrapper();
                callwrap.cCall = ccc;
                if(ccc.Disposition__c != 'Accept'){
                    callwrap.selected = false;
                }
                wrappedCall.add(callWrap);
                wrappedCallMap.put(ccc.Id, callwrap);*/
                chatMap.put(cChat.Id, cChat);
            }
            this.totalChats = this.chats.size();
    }
    public void updateLeads(){
        if(chats != null){
        update chats;
        }
        if(calls != null){
        update calls;
        }
        if(emails != null){
        update emails;
        }
    }
    public void updateCall(){
       Client_Call__C myCall = callMap.Get(tc);
       update myCall;        
    }
    public void updateCC(){
       Client_CC__C myCC = ccMap.Get(tc);
       update myCC;        
    }
    public void updateChat(){
       Client_Chat__c myChat = chatMap.Get(tc);
       update myChat;        
    }
}