+ Start a Discussion
Akash Garg 2Akash Garg 2 

Lookup field values depends on outputfield value in vf page.

Hi

I have a VF page called as tridentQuotePage on which i select the value of route from customobject name as Route__c.
I also added one outputfield on vf page whose value is getting from business type field of OPPORTUNITY Object which is the picklist with values Export and Domestic.
Now, i want when there is value Export on vf page then route should be filtered to certain value which contains X as second letter in Route__c object.
and 
when i select domestic then, it don't show the value which contains X as second letter in Route__c and show rest of the values.

My VF page is
<apex:page Controller="tridentOppDetailOnQuoteController">
      
    <apex:form id="myForm"> 
    <apex:inputHidden id="payid" value="{!paymentids}" />
    <div style="font-size:18px"> 
    <apex:PageMessages />
    </div>
    <center>
    <apex:commandButton action="{!cancelQuote}" value="Back" rendered="{!!render}" style="Color:blue;width:100px;height:28px;font-size:18px;"/></center>
    <apex:outputpanel rendered="{!render}">
        <apex:pageBlock id="PageBlock">
       
             <apex:pageblockSection columns="2" title="Quotation Details">
                 <apex:inputField value="{!quot.QuoteNumber}"/>
                 <apex:inputField value="{!quot.Inco_Terms__c}" required="true"/>
                 <apex:outputField value="{!opp.PaymentTerms__c}"/>
                 <apex:outputField value="{!opp.IncoTerm_1_opp__c}"/>
                   <!-- <apex:outputText >
          Payment Term  
                    <apex:inputtext value="{!lukupdoc2name}" style="align:left;" id="luckup2id" /><a href ="" style="cursor: pointer" onClick="javascript:return openDocumentPopup2(this.parentNode)" >
                    <img src="/s.gif" alt="Payment Lookup (New Window)" title="Payment 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';"  /></a>
              <br/>
                 
                </apex:outputText>-->
       <!-- <apex:pageBlockSectionItem >
                        <apex:outputLabel value="Payment Term"/>
                                <apex:outputPanel >
                                    <div class="requiredInput">
                                        <div class="requiredBlock"></div>
                                        <apex:inputtext value="{!lukupdoc2name}" style="align:left;" id="luckup2id" /><a href ="" style="cursor: pointer" onClick="javascript:return openDocumentPopup2(this.parentNode)" >
                    <img src="/s.gif" alt="Payment Lookup (New Window)" title="Payment 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';"  /></a>
        
              <br/>
                                    </div>
                                </apex:outputPanel>
                    </apex:pageBlockSectionItem> -->
                 <apex:inputField value="{!quot.Name}"/>
                 <apex:inputField value="{!quot.Inco_Term2__c}" required="true"/>
                 <apex:inputField value="{!quot.Terms_Conditions__c}" required="true"/>
                  <apex:inputField value="{!quot.Route_Name__c}" required="true"/>
                 <apex:outputField value="{!quot.Quote_Status__c}"/>
                 <apex:inputField value="{!quot.Description}"/>
                 <apex:outputField value="{!Opp.name}"/>
                 <apex:outputField value="{!opp.Sales_Area__c}"/> 
                 <apex:outputField value="{!opp.Required_Delivery_Date_First_Delivery__c}"/>
                 <apex:outputField value="{!opp.Accountid}"/>
                 <apex:outputField value="{!quot.Tentative_Delivery_Date__c}" />
                 <apex:outputField value="{!opp.Contact__c}"/>
                 <apex:outputField value="{!quot.Total_Quantity__c}"/>
                 
                 <apex:inputField value="{!quot.For_Record__c}"/>
                 <apex:outputField value="{!opp.Qty_UOM__c}"/> 
                 <apex:inputField value="{!quot.Validity_Date__c}" required="true"/>
                 <apex:outputField value="{!opp.Ship_To_Party__c}" />
                 <!--apex:outputField value="{!opp.Contact__c}" /> -->
                 <apex:outputField value="{!quot.Total_Value__c}"/>
                <!-- <apex:inputField value="{!quot.Payment_Terms__c}" required="true" id="Account"/>-->
                 <apex:outputField value="{!quot.Accepted_Rejected_By__c}"/>
                 <apex:outputField value="{!opp.Business_Type__c}"/>
             </apex:pageblockSection>
              <apex:pageBlockSection >
        
      </apex:pageBlockSection>
             <apex:pageblockSection columns="2" title="Customer Decline">
                 <apex:outputField value="{!quot.Decline_Reason__c}"/>
             </apex:pageblockSection>
             
             <apex:pageblockButtons >
                 <apex:commandButton action="{!saveProduct}" value="Save"/>
                 <apex:commandButton action="{!cancelQuote}" value="Cancel" immediate="true"/>
             </apex:pageblockButtons>
        </apex:pageBlock>  
        </apex:outputpanel>
    </apex:form>
<script type="text/javascript">
   var currConColumn = '';
                       
            function openDocumentPopup2(obj)
            {
                currConColumn = obj;
                var likeString = "{!Agentid}";   
                var pterms="{!quot.name}";                    
                var url ;
                url = "PaymentTerm_Lookup?likestring="+likeString;
                openWind(url);
               
                return false;
            }
             
            function openWind(URL)
            {
            
                curPopupWindow = window.open(URL, "_blank","width=500, height=400,dependent=no,resizable=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=1", false);            
            }
            
            function setSelectedDocumentDetails2(etId, etName )//, etsub)
            {   
                document.getElementById("j_id0:myForm:payid").value = etId;               
                var inputArr = currConColumn.getElementsByTagName('input');                            
                inputArr[0].value =  etName;
                inputArr[1].value =  etId;
                               
              
                if(curPopupWindow != null)                                                  
                    curPopupWindow.close(); 
                 
                currConColumn = null;
                return false;
                
            }
            
            

</script>
</apex:page>

My controller is 
public class tridentOppDetailOnQuoteController {

    public String lukupdoc2name { get; set; }
    public string hiddendocId{get;set;}
    public String hiddendoc2Id { get; set; }
    public string paymentids{get;set;}
    public String Agentid{ get; set; }
    List<payment_terms__c>  pt;
    List<Account>  acc;
    public boolean render { get; set; }
    public opportunity opp{get;set;}
    public Quote quot{get;set;}
    private Id id1{get;set;} // id of opp
   
    public tridentOppDetailOnQuoteController (){      
    render = true;   
   
        quot = new Quote();         
        Agentid = ApexPages.currentPage().getParameters().get('Agentid');
        id1 = ApexPages.currentPage().getParameters().get('Id');
        if(id1!=null){
                opp= [SELECT Id,Name,Sales_Area__c,SAP_Inquiry_Code__c,Program__r.name,Required_Delivery_Date_First_Delivery__c,
                      Contact__c,Qty_UOM__c,accountid,RecordType.developername,IncoTerm_1_opp__c,Ship_To_Party__c,PaymentTerms__c,Business_Type__c FROM opportunity WHERE Id =:ApexPages.currentPage().getParameters().get('Id')];
            
            if(opp.SAP_Inquiry_Code__c == null){
                   render = false;
                   ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'You cannot create a Quote until SAP Inquiry code is received from SAP'));
                }
               quot.Inco_Terms__c=[Select id,Inco_Terms__c from account where id=:Agentid ].Inco_Terms__c  ;  
              
     /*pt = [Select Id,Account__c,name, Primary__c from  payment_terms__c  where Account__c =: opp.accountid and primary__c = true];
         if(pt.size()>0){
            quot.Payment_Terms__c = pt[0].id;
            lukupdoc2name=pt[0].name;
            }
      else{quot.Payment_Terms__c = null;}*/
      
      acc=[Select Id from  Account  where Name =: opp.Ship_To_Party__c];
      if (acc.size()>0){
      quot.Ship_To_Party__c=acc[0].id;
      }
      else { quot.Ship_To_Party__c=null;}
   RecordType quoteRts =[SELECT Name,id,developername  FROM RecordType WHERE sObjectType='Quote' and developername =:opp.RecordType.developername]; 
   quot.RecordTypeId = quoteRts.id ;
        } }
     public PageReference saveProduct() {
          
          PageReference pr=null;
          try{ 
            //  quot.Business_Criteria__c = [Select Id from Business_Criteria__c where  name= '0000000000'].id;     
              quot.opportunityid=opp.id; 
              quot.agent__c = opp.accountid;
              quot.Required_Delivery_Date__c =opp.Required_Delivery_Date_First_Delivery__c ;
              quot.PaymentTerms__c = opp.PaymentTerms__c;
              quot.IncoTerm_1_quot__c = opp.IncoTerm_1_opp__c;
              quot.contactid= opp.contact__c;
             // quot.SalesArea__c = opp.Sales_Area__c;
              quot.Quantity_UOM__c = opp.Qty_UOM__c;  
              quot.Program__C = opp.Program__r.name;
              quot.Ship_To_Party__c= opp.Ship_To_Party__c;
              /*if(paymentids != '')quot.Payment_Terms__c=paymentids;
              else
              quot.Payment_Terms__c=pt[0].id;*/
              quot.New_Business_Type__c= opp.Business_Type__c;
              insert quot;    
              
             pr =  new PageReference('/' + quot.id); 
              
                       
          }           
          catch(DmlException e){    
         ApexPages.Message msg = new ApexPages.Message(Apexpages.Severity.ERROR,e.getdmlMessage(0));           
         ApexPages.addMessage(msg);               
                          
          }           
          
          return pr;     
          
      }
      
       public pagereference cancelQuote(){
           
           PageReference reference=new PageReference('/'+opp.id);
               reference.setRedirect(true);
               return reference; 
       }
       
     
     
                 
}


PLEASE HELP in geeting the required output.

Thank in advance for helping
Akash Garg 2Akash Garg 2
Can anyone have the solution for the above problem??