+ Start a Discussion
Niraj Kumar 9Niraj Kumar 9 

Vf page working fine in salesforce but not updating user field in salesforce1 after selection of user.

Hi,

Vf page working fine in salesforce but not updating user field in salesforce1 after selection of user.

Here is my code.
 
<apex:page id="pg" standardController="Siebel_Quote__c" extensions="RequestSiebelQuote" tabStyle="Siebel_Quote__c" action="{!CheckForSOS}" standardStylesheets="true">
<script>
    function test(){
    
     // alert('You are here');
        UsQe = document.getElementById('pg:frm:Pb:pbs:UsrSelLst').value;
        UsQeId = document.getElementById('pg:frm:Pb:pbs:UsrSelLst').value;
        UsQeId = document.getElementById('pg:frm:Pb:pbs:HdUsrSelId').value;
        var retvalId = UsQeId;
       // alert('test+'+retvalId);
         ReturnValueUpdateAction(retvalId);
    
    }
    
    
    function getCheckedValue() { 
    //alert('Inside JS');
     var rt = document.getElementById('pg:frm:Pblk:SelLstRT').value;
      var UsQe= '' ;
        if(document.getElementById('pg:frm:Pb:pbs:UsrSelLst') != null) 
      { 
    //   alert('text'+ document.getElementById('pg:frm:Pb:pbs:UsrSelLst').text);
    //   alert('value'+ document.getElementById('pg:frm:Pb:pbs:UsrSelLst').value);     

        UsQe = document.getElementById('pg:frm:Pb:pbs:UsrSelLst').value;
        UsQeId = document.getElementById('pg:frm:Pb:pbs:UsrSelLst').value;
      
       
        
        ownerUpdateAction(own,UsQeId,rt,main,contId);
      }

       var statustxt = document.getElementById('pg:frm:Pb:pbs:txtHd2').value;
      if(statustxt != '')
      { 
         UsQe=document.getElementById('pg:frm:Pb:pbs:txtHd2').value;
      }
       var UsQeId;
       var ch = false;
       var LUch = false;
      // var rt = document.getElementById('pg:frm:Pblk:SelLstRT').value;
       var radio = document.getElementsByName('sos');
       var LUradio = document.getElementsByName('LUsos');
       for(var j=0; j < radio.length; j++)
       {
       if(radio[j].checked)
       ch = true;
       }  
       
       for(var s=0; s < LUradio.length; s++)
       {
       if(LUradio[s].checked)
       LUch = true;
       }
        
        var own;
        var main;
        var contId;
        if(rt == '')
       {
       alert("Please select a Customer Admin Activity type and then proceed.");
        return false;
       }
       if(UsQe == '' && ch == false && LUch == false)
       {
       alert("Please select either User/Queue or select a member from Account Owner's Default Sales team as Owner or select a member from running user's Default Sales team as Owner");
       }
       else if(UsQe != '' && ch == true && LUch == true)
       {
       alert("Please select only a User/Queue or a member from the Account Owner's Default Sales Team or a member from the running user's Default Sales Team - Delete the User/Queue value if you want to select a Default Sales Team member"); 
       
       var radList = document.getElementsByName('sos');
        for (var r = 0; r < radList.length; r++) 
        {
        if(radList[r].checked) 
        radList[r].checked = false;
        }
        var LUradList = document.getElementsByName('LUsos');
        for (var m = 0; m < LUradList.length; m++) 
        {
        if(LUradList[m].checked) 
        LUradList[m].checked = false;
        }
        
       }
       
       else if(UsQe != '' && ch == true)
       {
       alert("Please select only a User/Queue or a member from the Account Owner's Default Sales Team - Delete the User/Queue value if you want to select a Default Sales Team member"); 
       
       var radList = document.getElementsByName('sos');
        for (var r = 0; r < radList.length; r++) 
        {
        if(radList[r].checked) 
        radList[r].checked = false;
        }
       }
        
       else if(UsQe != '' && LUch == true)
       {
       alert("Please select only a User/Queue or a member from the Running User's Default Sales Team - Delete the User/Queue value if you want to select a Default Sales Team member"); 
       
       var LUradList = document.getElementsByName('LUsos');
        for (var m = 0; m < LUradList.length; m++) 
        {
        if(LUradList[m].checked) 
        LUradList[m].checked = false;
        }
       }
       
       else if(ch == true && LUch == true)
       {
       alert("Please select either a member from the Account Owner's Default Sales Team or a member from the running user's Default Sales Team"); 
       
       var radList = document.getElementsByName('sos');
        for (var r = 0; r < radList.length; r++) 
        {
        if(radList[r].checked) 
        radList[r].checked = false;
        }
        var LUradList = document.getElementsByName('LUsos');
        for (var m = 0; m < LUradList.length; m++) 
        {
        if(LUradList[m].checked) 
        LUradList[m].checked = false;
        }
       }
        
       else if(UsQe != '' && ch == false && LUch == false)
        {
         if({!msc})
         {
            main=document.getElementById('txtUsrFrm').value;
            contId =document.getElementById('contId').value;
         }
          own=document.getElementById('pg:frm:Pb:pbs:txtHd2').value;
          UsQeId=document.getElementById('pg:frm:Pb:pbs:txtHdId').value;
          ownerUpdateAction(own,UsQeId,rt,main,contId);
        }
       
       else  if({!show} && ch == true){
        var arr = new Array();
        arr = document.getElementsByName('sos');
        if({!msc}){
         main=document.getElementById('txtUsrFrm').value;
         contId =document.getElementById('contId').value;
       }
       if(ch == true)
       {
        for(var i = 0; i < arr.length;i++)
           {
            var obj = document.getElementsByName('sos').item(i);
            if(obj.checked){
                 UsQeId=obj.value;
                 ch=true;
             }
           }
       }
           ownerUpdateAction(own,UsQeId,rt,main,contId);
       } 
       
       else  if({!showLU} && LUch == true){ 
        var arr1 = new Array();
        arr1 = document.getElementsByName('LUsos');
        
        if({!msc}){
         main=document.getElementById('txtUsrFrm').value;
         contId =document.getElementById('contId').value;
       }
       if(LUch == true)
       {    
           for(var a = 0; a < arr1.length;a++)
              {
            var obj1 = document.getElementsByName('LUsos').item(a);
            if(obj1.checked){
                 UsQeId=obj1.value;
                 ch1=true;
             }
           }
       }
           
           ownerUpdateAction(own,UsQeId,rt,main,contId);
       }
       
     }
     function openLookUp(id)
        {
             var newWindow = window.open( '/apex/Lookup_RQ?accId='+id , '_new', 'resizable=yes,scrollbars=yes,status=yes,toolbar=false,height=600,width=800,top=100,left=100');
             newWindow.creator=self;
        }
        
        function openQULookUp(id)
        {
            var txtval;
            var txtval1;
            txtval=document.getElementById('pg:frm:Pb:pbs:SelLst').value
            txtval1= '';
            if(document.getElementById('pg:frm:Pb:pbs:txtHd2') != null) 
               txtval1=document.getElementById('pg:frm:Pb:pbs:txtHd2').value;
            else {
               var p = document.getElementById('pg:frm:Pb:pbs:UsrSelLst').selectedIndex ;
               txtval1 = document.getElementById('pg:frm:Pb:pbs:UsrSelLst').options[p].text
             }
             
             if(txtval == 'User')
             { 
             var newWindow = window.open( '/apex/UsrLookup?UsrId='+txtval1+'&selected=user&accId='+id, '_new', 'resizable=yes,scrollbars=yes,status=yes,toolbar=false,height=600,width=800,top=100,left=100');
             newWindow.creator=self;
             }
             else if (txtval == 'Queue')
             {
             var newWindow = window.open( '/apex/QueLookup?QueId='+txtval1+'&selected=Queue&accId='+id, '_new', 'resizable=yes,scrollbars=yes,status=yes,toolbar=false,height=600,width=800,top=100,left=100');
             newWindow.creator=self;
             }
             
        }
  </script>
<apex:form id="frm">
 <apex:pagemessages />
  
  
  
   <apex:actionFunction name="ReturnValueUpdateAction" action="{!ReturnValueUpdate}"   rerender="pg:frm:Pb:pbs:OutList">
         <apex:param name="ReturnValId" assignTo="{!ReturnValId}" value="" id="RvId"/>
        
    </apex:actionFunction>     
  
  <apex:actionFunction name="ownerUpdateAction" action="{!OwnerUpdate}" rerender="frm">
         <apex:param name="UID" assignTo="{!UID}" value="" id="t"/>
         <apex:param name="UsQeId" assignTo="{!UsQeId}" value="" id="UQ"/>
         <apex:param name="rt" assignTo="{!rt}" value="" id="RT"/>
         <apex:param name="Con" assignTo="{!Con}" value="" id="l"/>
         <apex:param name="ContId" assignTo="{!ContId}" value="" id="s"/>
  </apex:actionFunction>
  
    
      
    <apex:pageBlock id="Pblk" title="Select 'Customer Admin Activity' type">  
     <apex:outputLabel id="OLb" style="vertical-align:text-top;font-weight : bold" value="Customer Admin Activity Type">
     <img src="/s.gif" alt="Help" class="helpOrb" title="{!helptext}"/></apex:outputLabel> 
       
         <apex:selectList value="{!RecordType}" size="1" id="SelLstRT">
          
         <apex:selectOptions value="{!RTValues}" id="SelOptIdRT"/>
         </apex:selectList>
     
    </apex:pageBlock> 
        
    <apex:pageBlock id="Pb" title="Select 'Customer Admin Activity Record' Owner">
        <apex:pageBlockSection id="pbs" title="Please assign this to a Sales Order Specialist from yours or the Account Owner Sales Team or Queue" >  
           
        
         

<!-- Your SOS-->
<apex:outputlabel style="font-weight:bold;margin-top:10px">Select from your Sales Order Specialist Team Members</apex:outputlabel><br/>
      <apex:pageBlockTable style="margin-bottom:20px" value="{!LoggedUTM}" var="o" >
              <apex:column headerValue="Name">
                  <apex:OutputText value="{!o.User.Name}"/>
              </apex:column>  
             <apex:column headerValue="Role">
                   <apex:OutputText value="{!o.User.tfcrmTeamRole__c}"/>
             </apex:column> 
             <apex:column headerValue="Select a Member">
                  <input type="radio" name='LUsos' value="{!o.User.Id}"/>               
             </apex:column>             
       </apex:pageBlockTable>
<br/>

<!-- AM SOS-->

          <apex:outputlabel style="font-weight:bold;margin-top:10px">OR Select from the Account Owner Sales Order Specialist Team Members</apex:outputlabel><br/>
       <apex:pageBlockTable style="margin-bottom:20px" value="{!utm}" var="o" >
              <apex:column headerValue="Name">
                  <apex:OutputText value="{!o.User.Name}"/>
              </apex:column>  
             <apex:column headerValue="Role">
                   <apex:OutputText value="{!o.User.tfcrmTeamRole__c}"/>
             </apex:column> 
             <apex:column headerValue="Select a Member">
                  <input type="radio" name='sos' value="{!o.User.Id}"/>               
             </apex:column>             
       </apex:pageBlockTable>  

<br/>
<!--U/Q lookup-->

<apex:outputlabel style="font-weight:bold;margin-top:10px">OR Search and select for a Sales Order Specialist or Queue</apex:outputlabel><br/>
<apex:outputPanel id="lookupQU"> 
            <apex:outputLabel id="Ol" style="text-align:left;font-weight : bold" value="Owner ">&nbsp;</apex:outputLabel>     

         
                <apex:selectList value="{!QueueUser}" size="1" id="SelLst"> 
                <apex:selectOptions value="{!Items}" id="SelOptId"/>   
                </apex:selectList>
                               &nbsp;
                <apex:outputpanel rendered="{!showLookup}">
                  <apex:inputText id="txtHd2" value="{!custAA.Owner.Name}"/> 
                 
                 <a href="#"  id="lookupPickTechMask1"  title="User or Queue LookUp (New Window)" onclick="openQULookUp('{!accountId}');">
                            <img src="/s.gif" alt="TechMask Lookup (New Window)"  class="lookupIcon" onblur="this.className = 

'lookupIcon';"    onfocus="this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 

'lookupIcon';"    onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" title="User or Queue LookUp 

(New  Window)"/>
                  </a>             
                </apex:outputpanel>
                <apex:outputpanel rendered="{!NOT(showLookup)}" id="OutList">
                <apex:inputHidden id="HdUsrSelId" value="{!ReturnValId}"/>
                 <apex:selectList value="{!selectedUser}" size="1" id="UsrSelLst">
                   <apex:selectOptions value="{!SelectedUserList}"  id="UsrSelOpt" />
                   </apex:selectList>
                   <a href="#"  id="lookupPickTechMask1"  title="User or Queue LookUp (New Window)" onclick="openQULookUp

('{!accountId}');">
                            <img src="/" alt="TechMask Lookup (New Window)"  class="lookupIcon" onblur="this.className = 

'lookupIcon';"    onfocus="this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 

'lookupIcon';"    onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" title="User or Queue LookUp 

(New  Window)"/>
                  </a>
                  <apex:pagemessages />
                </apex:outputpanel>
                <apex:inputHidden id="txtHdId" value="{!usqe}"/>
            </apex:outputPanel>
       
       
      
     </apex:pageBlockSection>
      </apex:pageBlock>      <br />  
    

        
     <apex:pageBlock title="Select a Main Sales Contact from the Account Hierarchy" rendered="{!(msc)}" helpTitle="Help for this Page" helpUrl="help">
         <apex:pageBlockSection columns="2">
            <apex:outputField value="{!conFunAcc.Account_Id__c}"/> 
             
             <apex:pageblockSectionItem >
                 <apex:outputlabel style="vertical-align:text-top;font-weight : bold">Main Sales Contact</apex:outputlabel>
                 <apex:outputPanel id="lookup">
                 <input type="text" id="txtUsrFrm"/>
                 <input type="hidden" id="contId"/>                
                     <apex:inputHidden id="txtHd" value="{!val}"/>
                     <a href="#"  id="lookupPickTechMask"  title="Main Sales Contact Lookup (New Window)" onclick="openLookUp('{!conFunAcc.Account_Id__c}');">
                            <img src="/s.gif" alt="TechMask Lookup (New Window)"  class="lookupIcon" onblur="this.className = 'lookupIcon';"    onfocus="this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 'lookupIcon';"    onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" title="Main Sales Contact Lookup (New  Window)"/>
                         </a>
                 </apex:outputPanel> 
             </apex:pageblockSectionItem>
           </apex:pageBlockSection>
         </apex:pageBlock>
         <apex:outputLabel rendered="{!(msc)}" id="Ol" style="text-align:left;font-weight : bold" value="OR"></apex:outputLabel>
         
         
          <apex:outputPanel rendered="{!(!flag)}">
     <a href="/003/e?retURL=%2F003%2Fo&RecordType=0124000000059h2&ent=Contact&con4={!accName}">Create New Contact</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     </apex:outputPanel>
     <apex:outputPanel rendered="{!(flag)}">
<p>     <a href="/{!accountId}">Click here to assign a Main Sales Contact to the Account</a></p>
     </apex:outputPanel>
    <apex:outputPanel >
         <table>
               <tr>
               <td>&nbsp;</td>
               </tr>
               <tr>
               <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
               <input type="button" onclick="JavaScript:getCheckedValue(); return false;"  value="Next"  id="nxt" /></td></tr>
        </table>
    </apex:outputPanel>
  </apex:form>
  <script>
      allradios = document.forms['pg:frm'].sos;
      if(allradios.length){
          allradios[0].checked = false;
      }else{
          allradios.checked = false;
      }     
      
      LUallradios = document.forms['pg:frm'].LUsos;
      if(LUallradios.length){
          LUallradios[0].checked = false;
      }else{
          LUallradios.checked = false;
      } 
      
  </script>
</apex:page>

 
James LoghryJames Loghry
I'm not sure how you expect us to read this and magically figure out your answer.  There is quite a  lot going on in this VF page.  If you post the extension as well and provide us some more specific information (such as the line of code and circumstance where the user field should be updated), that would help us investigate this further.

 
Niraj Kumar 9Niraj Kumar 9
Hi James,
Sorry James, I am new to this domain.Thats why mistake commited. Sorry once again.
Here is the code:::
<apex:outputlabel style="font-weight:bold;margin-top:10px">OR Search and select for a Sales Order Specialist or Queue</apex:outputlabel><br/>
<apex:outputPanel id="lookupQU"> 
            <apex:outputLabel id="Ol" style="text-align:left;font-weight : bold" value="Owner ">&nbsp;</apex:outputLabel>     

         
                <apex:selectList value="{!QueueUser}" size="1" id="SelLst"> 
                <apex:selectOptions value="{!Items}" id="SelOptId"/>   
                </apex:selectList>
                               &nbsp;
                <apex:outputpanel rendered="{!showLookup}">
                  <apex:inputText id="txtHd2" value="{!custAA.Owner.Name}"/> 
                 
                 <a href="#"  id="lookupPickTechMask1"  title="User or Queue LookUp (New Window)" onclick="openQULookUp('{!accountId}');">
                            <img src="/s.gif" alt="TechMask Lookup (New Window)"  class="lookupIcon" onblur="this.className = 

'lookupIcon';"    onfocus="this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 

'lookupIcon';"    onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" title="User or Queue LookUp 

(New  Window)"/>
                  </a>             
                </apex:outputpanel>
                <apex:outputpanel rendered="{!NOT(showLookup)}" id="OutList">
                <apex:inputHidden id="HdUsrSelId" value="{!ReturnValId}"/>
                 <apex:selectList value="{!selectedUser}" size="1" id="UsrSelLst">
                   <apex:selectOptions value="{!SelectedUserList}"  id="UsrSelOpt" />
                   </apex:selectList>
                   <a href="#"  id="lookupPickTechMask1"  title="User or Queue LookUp (New Window)" onclick="openQULookUp

('{!accountId}');">
                            <img src="/" alt="TechMask Lookup (New Window)"  class="lookupIcon" onblur="this.className = 

'lookupIcon';"    onfocus="this.className = 'lookupIconOn';" onmouseout="this.className = 'lookupIcon';this.className = 

'lookupIcon';"    onmouseover="this.className = 'lookupIconOn';this.className = 'lookupIconOn';" title="User or Queue LookUp 

(New  Window)"/>
                  </a>
                  <apex:pagemessages />
                </apex:outputpanel>
                <apex:inputHidden id="txtHdId" value="{!usqe}"/>
            </apex:outputPanel>
       
       
      
     </apex:pageBlockSection>
      </apex:pageBlock>      <br />

function openQULookUp(id)
        {
            var txtval;
            var txtval1;
            txtval=document.getElementById('pg:frm:Pb:pbs:SelLst').value
            txtval1= '';
            if(document.getElementById('pg:frm:Pb:pbs:txtHd2') != null) 
               txtval1=document.getElementById('pg:frm:Pb:pbs:txtHd2').value;
            else {
               var p = document.getElementById('pg:frm:Pb:pbs:UsrSelLst').selectedIndex ;
               txtval1 = document.getElementById('pg:frm:Pb:pbs:UsrSelLst').options[p].text
             }
             
             if(txtval == 'User')
             { 
             var newWindow = window.open( '/apex/UsrLookup?UsrId='+txtval1+'&selected=user&accId='+id, '_new', 'resizable=yes,scrollbars=yes,status=yes,toolbar=false,height=600,width=800,top=100,left=100');
             newWindow.creator=self;
             }
             else if (txtval == 'Queue')
             {
             var newWindow = window.open( '/apex/QueLookup?QueId='+txtval1+'&selected=Queue&accId='+id, '_new', 'resizable=yes,scrollbars=yes,status=yes,toolbar=false,height=600,width=800,top=100,left=100');
             newWindow.creator=self;
             }
Here is the controller:::::

 
public pageReference OwnerUpdate()
    {
      showLookup = true ;
      System.debug('Owner' + UID + 'UsQeId' + UsQeId + 'Con' + Con + 'ContId' + ContId);
      String cont = conFunAcc.Contact_Id__c;  
      String recTy;

    
      String UerId;
      PageReference pageRef ;      
     if(rt != '')
      {
      RecordType recType = [select Name,id from RecordType where RecordType.SobjectType = 'Siebel_Quote__c' and Name =:rt];
      recTy = recType.id;   
       System.debug('name' + recType.name + 'Id' + recType.id); 
      }
    
      if(UID != '' && QueueUser == 'User')
      {
        System.debug('****************test11111***'+selectedUser)   ;
        if( selectedUser == '' || selectedUser == null ) {
        System.debug('****************test***'+selectedUser)    ;
        string str = '%'+UID+'%';
        list<User> uer = [select id, name,tfcrmTeamRole__c from User where tfcrmTeamRole__c = 'Sales Order Specialist' and IsActive = true and ((NOT Profile.Name like 'Account Gateway%') OR (NOT Profile.Name like 'My Thomson Reuters%')) and name Like : str ];
        if(uer.size() > 1)
        {
          for(User ur : uer){
            showLookup = false ;
            SelectedUserList.add(new selectoption (ur.id,ur.Name));
            UerId = uer[0].Id;
            selectedUser = uer[0].Id;
            System.debug('***************user selected from dropdown **' + UerId)   ;
         }

            System.debug('****************uer.size() > 1***')   ;
            ApexPages.Message errMsg= new ApexPages.Message(ApexPages.severity.ERROR, 'Multiple Sales Order Specialists found. Select from the drop-down or click icon to refine search.');  
            ApexPages.addMessage(errMsg);
          return null;
        }else if(uer.size() == 0 ){
            System.debug('***************uer.size() == 0**')    ;
            ApexPages.Message errMsg= new ApexPages.Message(ApexPages.severity.ERROR, 'No matching Sales Order Specialists found.');  
            ApexPages.addMessage(errMsg);
            return null;
            }

        else if(uer.size() == 1 ){
           System.debug('***************er.size() == 1**')  ;
           UerId = uer[0].Id;
           System.debug('***************user selected if list size is 1**' + UerId) ;
             }

        
        }
            else 
            {


            system.debug('**** In the inner else selectedUser *****' + selectedUser);
               UerId = selectedUser;
               system.debug('**** In the inner else section *****' + UerId);
            }

      }
      else
      {
        system.debug('**** In the outer else UsQeId *****' + UsQeId);
          UerId = UsQeId;
          system.debug('**** In the Outer else section *****' + UerId);
      }
      
      if(UID != '' && QueueUser == 'Queue')
      {
      if( selectedUser == '' || selectedUser == null ) 
        {

        System.debug('****************test***'+selectedUser)    ;
        string str = '%'+UID+'%';
        list<QueueSobject> Qu = [Select Queue.Name, QueueId From QueueSobject where SobjectType ='Siebel_Quote__C' and Queue.Name Like : str ];
        if(Qu.size() > 1){
          for(QueueSobject Qe : Qu){
            showLookup = false ;
            SelectedUserList .add(new selectoption (Qe.QueueId,Qe.Queue.Name));
            UerId = Qu[0].QueueId;
            selectedUser = Qu[0].QueueId;
          }

            System.debug('****************Qu.size() > 1***')    ;
            ApexPages.Message errMsg= new ApexPages.Message(ApexPages.severity.ERROR,'Multiple Queues found. Select from the drop-down or click icon to refine search.');  
            ApexPages.addMessage(errMsg);

          return null;
        }else if( Qu.size() == 0){
            System.debug('***************Qu.size() == 0**') ;
          ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'No matching Queue found.'));
           return null;
        }else if(Qu.size() == 1 ){
           System.debug('***************er.size() == 1**')  ;
           UerId = Qu[0].QueueId;
        }
        }else 
           UerId = selectedUser;
      }
     /* else{
        system.debug('Else you came here');
          UerId = UsQeId;
      }*/
      
      system.debug('  CONTACT ID   '+cntid);
      if((OppId == null || OppId == '') && (CntId == null || CntId == '') && ( AccId == null ||AccId == '') )
      {
        pageRef = new PageReference('/a1m/e?retURL=%2F'+'a1m'+'&00N40000002R00z=' + UerId+'&RecordType=' + recTy+'&nooverride=1');
      }
      
      
      if((OppId == null || OppId == '') && (CntId != null && CntId != '') && ( AccId != null && AccId != '') )
      {
        pageRef = new PageReference('/a1m/e?CF00N40000002R00n='+ nomUtil.urlEncode(contactName) +'&CF00N40000002R00n_lkid='+CntId+'&retURL=%2F'+CntId+'&00N40000002R00z=' + UerId+'&RecordType=' + recTy+'&CF00N40000002R00m='+ nomUtil.urlEncode(accN[0].Name) +'&CF00N40000002R00m_lkid='+AccId+'&CF00N40000001nb0p='+Con + '&CF00N40000001nb0p_lkid='+ ContId+'&nooverride=1');
      }
      
      if((OppId == null || OppId == '') && (CntId != null && CntId != '') && ( AccId != null && AccId != '') && (recTy=='0124000000015SgAAI' || recTy=='0124000000016lkAAA'))
      {
        pageRef = new PageReference('/apex/customeradminactivity?CF00N40000002R00n='+ nomUtil.urlEncode(contactName) +'&CF00N40000002R00n_lkid='+CntId+'&retURL=/'+CntId+'&saveURL=/apex/displaypli&00N40000002R00z=' + UerId+'&RecordType=' + recTy+'&CF00N40000002R00m='+ nomUtil.urlEncode(accN[0].Name) +'&CF00N40000002R00m_lkid='+AccId+'&CF00N40000001nb0p='+Con + '&CF00N40000001nb0p_lkid='+ ContId+'&nooverride=1');
      }
      
      if((OppId == null || OppId == '') && (CntId == null || CntId == '') && ( AccId != null && AccId != ''))
      {
      pageRef = new PageReference('/a1m/e?CF00N40000002R00m='+ nomUtil.urlEncode(accN[0].Name) +'&CF00N40000002R00m_lkid='+AccId+'&retURL=%2F'+AccId+'&00N40000002R00z=' + UerId+'&RecordType=' + recTy+'&CF00N40000001nb0p='+Con+'&CF00N40000001nb0p_lkid=' + ContId+'&nooverride=1');
      }
      
      if((OppId == null || OppId == '') && (CntId == null || CntId == '') && ( AccId != null && AccId != '') && (recTy=='0124000000015SgAAI' || recTy=='0124000000016lkAAA'))
      {
      pageRef = new PageReference('/apex/customeradminactivity?CF00N40000002R00m='+ nomUtil.urlEncode(accN[0].Name) +'&CF00N40000002R00m_lkid='+AccId+'&retURL=/'+AccId+'&saveURL=/apex/displaypli&00N40000002R00z=' + UerId+'&RecordType=' + recTy+'&CF00N40000001nb0p='+Con+'&CF00N40000001nb0p_lkid=' + ContId+'&nooverride=1');
      }
      
      if( OppId != null && OppId != '' && (recTy=='0124000000015SgAAI' || recTy=='0124000000016lkAAA'))
      {      
        //system.debug('Entered display PLI loop : Rectype ID:'+recTy);
        pageRef = new PageReference('/apex/customeradminactivity?CF00N40000001nb0s='+ nomUtil.urlEncode(Optm[0].Name) +'&CF00N40000001nb0s_lkid='+OppId+'&retURL=/'+OppId+'&saveURL=/apex/displaypli&CF00N40000002R00m='+ nomUtil.urlEncode(accN[0].Name) +'&CF00N40000002R00m_lkid='+AccId+'&00N40000002R00z=' + UerId+'&RecordType=' + recTy+'&CF00N40000001nb0p='+Con+'&CF00N40000001nb0p_lkid=' + ContId+'&nooverride=1');
      }
      
    /*  if((OppId == null || OppId == '') && (CntId != null && CntId != '') && ( AccId != null && AccId != '') && (recTy=='0124000000015dZAAQ' || recTy=='0124000000016lkAAA'))
      {
        pageRef = new PageReference('/apex/customeradminactivity?CF00N40000002R00n='+ nomUtil.urlEncode(contactName) +'&CF00N40000002R00n_lkid='+CntId+'&retURL=/'+CntId+'&saveURL=/apex/displaypli&00N40000002R00z=' + UerId+'&RecordType=' + recTy+'&CF00N40000002R00m='+ nomUtil.urlEncode(accN[0].Name) +'&CF00N40000002R00m_lkid='+AccId+'&CF00N40000001nb0p='+Con + '&CF00N40000001nb0p_lkid='+ ContId+'&nooverride=1');
      }
      
      if((OppId == null || OppId == '') && (CntId == null || CntId == '') && ( AccId != null && AccId != '') && (recTy=='0124000000015dZAAQ' || recTy=='0124000000016lkAAA'))
      {
      pageRef = new PageReference('/apex/customeradminactivity?CF00N40000002R00m='+ nomUtil.urlEncode(accN[0].Name) +'&CF00N40000002R00m_lkid='+AccId+'&retURL=/'+AccId+'&saveURL=/apex/displaypli&00N40000002R00z=' + UerId+'&RecordType=' + recTy+'&CF00N40000001nb0p='+Con+'&CF00N40000001nb0p_lkid=' + ContId+'&nooverride=1');
      }
      
      if( OppId != null && OppId != '' && (recTy=='0124000000015dZAAQ' || recTy=='0124000000016lkAAA'))
      {      
        //system.debug('Entered display PLI loop : Rectype ID:'+recTy);
        pageRef = new PageReference('/apex/customeradminactivity?CF00N40000001nb0s='+ nomUtil.urlEncode(Optm[0].Name) +'&CF00N40000001nb0s_lkid='+OppId+'&retURL=/'+OppId+'&saveURL=/apex/displaypli&CF00N40000002R00m='+ nomUtil.urlEncode(accN[0].Name) +'&CF00N40000002R00m_lkid='+AccId+'&00N40000002R00z=' + UerId+'&RecordType=' + recTy+'&CF00N40000001nb0p='+Con+'&CF00N40000001nb0p_lkid=' + ContId+'&nooverride=1');
      }*/
      
      else if(OppId != null && OppId != '')
      {
        //system.debug('Exitloop : Rectype ID:'+recTy);
        pageRef = new PageReference('/a1m/e?CF00N40000001nb0s='+ nomUtil.urlEncode(Optm[0].Name) +'&CF00N40000001nb0s_lkid='+OppId+'&retURL=%2F'+OppId+'&CF00N40000002R00m='+ nomUtil.urlEncode(accN[0].Name) +'&CF00N40000002R00m_lkid='+AccId+'&00N40000002R00z=' + UerId+'&RecordType=' + recTy+'&CF00N40000001nb0p='+Con+'&CF00N40000001nb0p_lkid=' + ContId+'&nooverride=1');
      }
      
     // system.debug('test******************8888'+)

      system.debug('****** List value ownupd *********' + SelectedUserList);      
      pageRef.setRedirect(true);
      system.debug('  PAGE REF   '+pageRef);
      return pageRef;