1

Visualforce:

<apex:page standardController="Quote__c" extensions="createorder"  sidebar="false" showHeader="false" standardStylesheets="true" id="page" tabStyle="Quote__c"> 
<html>
<apex:includeScript value="{!URLFOR($Resource.JqueryA, 'js/jquery-1.6.2.min.js')}"/>
        <apex:includeScript value="{!URLFOR($Resource.JqueryA, 'js/jquery-ui-1.8.16.custom.min.js')}"/>
        <apex:stylesheet value="{!URLFOR($Resource.JqueryA, 'css/ui-lightness/jquery-ui-1.8.16.custom.css')}"/>
<center><u>CREATE ORDER ON THE FRANCE ERP </u></center><br/><br/>
<center>
<apex:form id="myform">     
<table width="90%"  border="1">
            <tr>
                    <td width="25%" >
                   <b><u> Customer Po Number :</u></b><td colspan="4">
                   <apex:panelGroup rendered="{!Quote__c.Or_customer_PO_Number__c<>NULL}">
                   <apex:inputtext value="{!Quote__c.Or_customer_PO_Number__c}" style="width:800px;"/>
                   </apex:panelGroup>
                   <apex:panelGroup rendered="{!Quote__c.Or_customer_PO_Number__c==NULL}">
                   <apex:inputtext value="{!customerponumber}" style="width:800px;"/>
                   </apex:panelGroup>
                   </td>
                   </td>
            </tr>
              <tr>
                   <td>

                   <b><u>SUB/CustomerID(Accountcode) :</u> </b><td colspan="3"> <apex:outputField value="{!Quote__c.Account_Name__r.Account_Code__c  }"/></td>
                   </td>  
                   <td>
                   <apex:panelGroup rendered="{!Quote__c.Or_customerid__c<>NULL}">
                   <apex:inputtext value="{!Quote__c.Or_customerid__c}" />
                   </apex:panelGroup>
                   <apex:panelGroup rendered="{!Quote__c.Or_customerid__c==NULL}">
                    <apex:inputtext value="{!test}" />
                   </apex:panelGroup>
                   </td>
              </tr>
            <tr>
                   <td>     
                  <b><u>Company Name :</u> </b> <td colspan="3"><apex:outputField value="{!Quote__c.Account_Name__r.Name}"/> </td> 
                </td>
                    <td>
                   <!--  <apex:panelGroup rendered="{!Quote__c.Or_Account_name__c<>NULL}">
                   <apex:inputtext value="{!Quote__c.Or_Account_name__c}" />
                   </apex:panelGroup>
                   <apex:panelGroup rendered="{!Quote__c.Or_Account_name__c==NULL}">

                   </apex:panelGroup>-->
                   <apex:inputtext value="{!test1}" />
                   </td>
            </tr>
            <tr>
                 <td>     
                   <b><u>Type Of Address :</u> </b> <td><center><b><u>Invoice Address(salesforce)</u></b></center></td>
                </td>
                   <td>
                   <center><b><u>Delivery address(salesforce)</u></b></center>
                   </td>
                   <td>
                   <center><b><u>Invoice Address</u></b></center>
                   </td>
                   <td>
                   <center><b><u>Delivery Address</u></b></center>
                   </td>
            </tr>
            <tr>
                 <td>     
                   <b><u>Address Line 1 :</u> </b> <td><apex:outputField value="{!Quote__c.Bill_To_Street__c }"/>  </td>
                </td>
                   <td>
                 <apex:inputtext value="{!test18}" />
                   </td>
                   <td>
                 <apex:panelGroup rendered="{!Quote__c.Or_invoiceadd1__c<>NULL}">
                   <apex:inputtext value="{!Quote__c.Or_invoiceadd1__c}" />
                   </apex:panelGroup>
                   <apex:panelGroup rendered="{!Quote__c.Or_invoiceadd1__c==NULL}">
                    <apex:inputtext value="{!test19}" />
                    </apex:panelGroup>
                   </td>
                   <td>
                <apex:inputtext value="{!test20}" />
                   </td>
            </tr>
            <tr>
                 <td>     
                   <b><u>Address Line 2 :</u> </b><td> <apex:outputField value="{!Quote__c.Bill_To_State_Province__c }"/>  </td>
                </td>
                   <td>
               <apex:inputtext value="{!test2}" />
                   </td>
                     <td>
                   <apex:panelGroup rendered="{!Quote__c.Or_invoiceadd2__c<>NULL}">
                   <apex:inputtext value="{!Quote__c.Or_invoiceadd2__c}" />
                   </apex:panelGroup>
                   <apex:panelGroup rendered="{!Quote__c.Or_invoiceadd2__c==NULL}">
                    <apex:inputtext value="{!test3}" />
                    </apex:panelGroup>
                   </td>
                   <td>
                  <apex:inputtext value="{!test4}" />
                   </td>
            </tr>
            <tr>
                <td>     
                   <b><u>Customer Zip Code :</u> </b><td> <apex:outputField value="{!Quote__c.Bill_To_Zip_Postal_Code__c }"/>  </td>
                </td>
                   <td>
                   <apex:inputtext value="{!test5}" />
                   </td>
                     <td>
                   <apex:panelGroup rendered="{!Quote__c.Or_invoiceadd3__c<>NULL}">
                   <apex:inputtext value="{!Quote__c.Or_invoiceadd3__c}" />
                   </apex:panelGroup>
                   <apex:panelGroup rendered="{!Quote__c.Or_invoiceadd3__c==NULL}">
                    <apex:inputtext value="{!test6}" />
                    </apex:panelGroup>
                   </td>
                    <td>
                   <apex:inputtext value="{!test7}" />
                   </td>
            </tr>
            <tr>
                <td>     
                   <b><u>Customer City :</u> </b> <td><apex:outputField value="{!Quote__c.Bill_To_City__c }"/>  </td>
                </td>
                   <td>
                  <apex:inputtext value="{!test8}" />
                   </td>  <td>
                  <apex:panelGroup rendered="{!Quote__c.Or_invoiceadd4__c<>NULL}">
                   <apex:inputtext value="{!Quote__c.Or_invoiceadd4__c}" />
                   </apex:panelGroup>
                   <apex:panelGroup rendered="{!Quote__c.Or_invoiceadd4__c==NULL}">
                    <apex:inputtext value="{!test9}" />
                    </apex:panelGroup>
                   </td>
                   <td>
                   <apex:inputtext value="{!test10}" />
                   </td>
            </tr>
            <tr>   
                <td>     
                   <b><u>Customer Country</u> </b><td> <apex:outputField value="{!Quote__c.Bill_To_Country__c }"/>  </td>
                </td>
                    <td>
                   <apex:inputtext value="{!test11}" />
                   </td>  <td>
                   <apex:panelGroup rendered="{!Quote__c.Or_invoiceadd5__c<>NULL}">
                   <apex:inputtext value="{!Quote__c.Or_invoiceadd5__c}" />
                   </apex:panelGroup>
                   <apex:panelGroup rendered="{!Quote__c.Or_invoiceadd5__c==NULL}">
                    <apex:inputtext value="{!test12}" />
                    </apex:panelGroup>
                   </td>
                   <td>
                   <apex:inputtext value="{!test13}" />
                   </td>
            </tr>
            <tr>
                <td>
                <b><u>Contact Name :</u> </b><td colspan="3"> <apex:outputField value="{!Quote__c.Contact_Name__r.Name}"/> </td> 
                </td>
                 <td> 
                    <apex:inputField id="Account" value="{!q.Or_contact_Name__c}">
                    <apex:actionSupport event="onchange" action="{!valueToConInfo}" />
                    </apex:inputField>
               <apex:commandButton onclick="window.open('{!URLFOR($Action.Contact.NewContact,null,[con4_lkid=id],true)}','height=400,location=no,resizable=yes,toolbar=no,status=no,menubar=no,scrollbars=1', 1);" value="Create contact"/>               
                   </td>
            </tr>
            <tr>
                 <td>
                <b><u>Contact Phone :</u> </b><td colspan="3"> <apex:outputField value="{!Quote__c.Phone__c}"/></td>  
                </td>
                   <td>
                  <apex:inputField value="{!q.Or_contact_Phone__c}"/>
                   </td>
            </tr>
            <tr>
                 <td>
                <b><u>Contact Fax :</u> </b> <td colspan="3"><apex:outputField value="{!Quote__c.Fax__c}"/> </td> 
                </td>
                    <td>
                   <apex:inputField value="{!q.Or_contact_Fax__c}"/>
                   </td>
            </tr>
            <tr>
                 <td>
                <b><u>Contact Email :</u> </b> <td colspan="3"><apex:outputField value="{!Quote__c.Email__c}"/></td>  

                   <td>
                                  <apex:inputField value="{!q.Or_contact_Email__c}"/> 
                   </td>
                    </td>
            </tr>
            <tr>
                 <td >
               <b><u> Carrier :</u> </b> <td colspan="4">
               <apex:panelGroup rendered="{!Quote__c.Or_carrier__c<>NULL}">
                   <apex:inputtext value="{!Quote__c.Or_carrier__c}" />
                   </apex:panelGroup>
                   <apex:panelGroup rendered="{!Quote__c.Or_carrier__c==NULL}">
                   <apex:inputtext value="{!Carrier}"/>
                    </apex:panelGroup>

               </td>
                </td>

            </tr>
            <tr>
               <td >
                   <b><u>Order Date : </u></b><td colspan="4"> 
                   <apex:panelGroup rendered="{!Quote__c.Or_orderdate__c<>NULL}">
                   <apex:inputtext value="{!Quote__c.Or_orderdate__c}" />
                   </apex:panelGroup>
                   <apex:panelGroup rendered="{!Quote__c.Or_orderdate__c==NULL}">
                   <apex:inputText value="{!orderdate}" size="20" id="teja1" onfocus="DatePicker.pickDate(false, 'page:myform:teja1', false);" />
                    </apex:panelGroup>
                   </td>
               </td>
           </tr>
           <!--<tr>
               <td >
                   <b><u>Comment : </u></b><td colspan="4"><apex:inputtext value="{!Comment}"/></td>
               </td>
           </tr>-->
            <tr>
                 <td >
                <b><u>Quotation Number :</u> </b> <td colspan="4"><apex:outputField value="{!Quote__c.Quote_Number_New__c}"/></td>  
                </td>
            </tr>
        </table><br/><br/>
<table width="100%" border="0" cellspacing="0" cellpadding="0" >
              <tr >                    
                    <td><b>Pos</b></td>
                    <td><b>NICOMATIC P/N</b></td>
                    <td><b>Client P/N</b></td>
                    <td><b>Quantity Ordered</b></td>
                    <td><b>Requested Date &nbsp;</b></td>
                    <td><b>Discount</b></td>
                    <td><b>Unit Price &nbsp;</b></td>                             
                    <td>Add</td>
</tr>
<tr>
                <apex:variable value="{!1}" var="rowNum"/>
                <apex:repeat value="{!q1}" var="i">
                   <table cellspacing = "0" cellpadding = "0" border = "1" width = "90%" id="table-data">
                      <tr class="tr_clone">
                        <td  ><apex:outputText value="{!FLOOR(rowNum)}" style="align:center;"/></td>
                        <td class = "tdCustom" ><apex:outputField value="{!i.name}" /><apex:inputtext /></td>
                        <td class = "tdCustom" ><apex:outputField value="{!i.Client_P_N__c}" /><apex:inputtext /></td>
                        <td class = "tdCustom" style="width:100px;" ><apex:inputField value="{!i.Final_Quantity__c}" style="width:100px"/></td>
                        <td class = "tdCustom" style="width:100px;" ><apex:inputField value="{!i.Requested_Date__c}" /></td>
                        <td class = "tdCustom" ><apex:inputfield value="{!i.Final_Discount__c}"/></td>
                        <td class="td1" style="width:100px;"><apex:inputfield value="{!i.Final_Price__c}" style="width:100px"/></td>   
                      <td><input type="button" name="add" value="Add" class="tr_clone_add"/></td>
                      <td><input type="button" value="Delete" onclick="deleteRow(this)" style="display: none;" class="tr_clone_delete"/></td>
                        </tr>
                        </table>       
                    <apex:variable var="rowNum" value="{!rowNum + 1}"/>
                </apex:repeat>
                </tr>
                </table>
<script>
$("input.tr_clone_add").live('click', function() {
    var $tr    = $(this).closest('.tr_clone');
    var $tds = $(this).closest('.tr_clone').children('td');
        $row = $("<tr></tr>");
           $row.append($tds.eq(0).clone()).append($tds.eq(1).clone()).append($tds.eq(2).clone()).append($tds.eq(3).clone()).append($tds.eq(4).clone()).append($tds.eq(5).clone()).append($tds.eq(6).clone()).append($tds.eq(8).clone());;
    $row.find(':button').css('display', 'block');   
    var $clone ;

    $tr.after($row);      
     $clone.find('.td1').val('');
});
</script>
<script>
$(document).ready(function(){
  $(".tr_clone_delete").live('click', function() {
      var $tr = $(this).closest('tr');
      $tr.remove();
  });
});
</script>
<apex:commandButton value="Save" action="{!Save}"/> 
</apex:form>
</center>                                        
</html>
</apex:page>

Controller:

public class createorder {
public Contact cont=new Contact();
Public Id conId;
public id id{get; set;}
    public quote__c q   {get;set;}
    public List<Quote_line_Item__c> q1 {get;set;}
    public List<Quote_line_Item__c> lineitemdata {get;set;}
    public List<batch__c> modifiedbatch=new List<batch__c>();
    public  List<batch__c> finalbatch=new List<batch__c>() ;
    public date orderdate{get;set;}
    public List<batch__C> lstbatch {get;set;}
    public String quoteId{get;set;}
    public String imageURL{get;set;}
    public date date1{get;set;}
    public date date2{get;set;}
    public String customerponumber{get;set;}
    public String Carrier{get;set;}
    public String comment{get;set;}
    public String quantity{get;set;}
    public boolean discount{get;set;}
    public decimal price{get;set;}
    public String inputvalue{get;set;}
    public quote__c quote{get;set;}
    public string test{get;set;}
    public string test1{get;set;}
    public string test2{get;set;}
    public string test3{get;set;}
    public string test4{get;set;}
    public string test5{get;set;}
    public string test6{get;set;}
    public string test7{get;set;}
    public string test8{get;set;}
    public string test9{get;set;}
    public string test10{get;set;}
    public string test11{get;set;}
    public string test12{get;set;}
    public string test13{get;set;}
    public string test14{get;set;}
    public string test15{get;set;}
    public string test16{get;set;}
    public string test17{get;set;}
    public string test18{get;set;}
    public string test19{get;set;}
    public string test20{get;set;}
    public string conname{get;set;}
    //QSA_Name__c,
    public createorder(ApexPages.StandardController controller) {
    q1 = [select id,Name,Client_P_N__c, final_quantity__c, Final_Discount__c, Requested_Date__c,Final_Price__c from quote_line_item__c WHERE quote1__c = : Apexpages.currentPage().getParameters().get('Id')];
      q= [select Contact_Name__r.Name,Account_Code__c,QSA_Name__c,Account_Name__r.Name,Account_Name__r.Account_Code__c ,id,Or_invoiceadd1__c,Or_invoiceadd2__c,Or_invoiceadd3__c,Or_invoiceadd4__c,Or_Carrier__c,Or_orderdate__c,Or_invoiceadd5__c,Or_contact_Name__r.accountid,Or_customer_PO_Number__c,Or_customerid__c,Or_Account_name__c,Quote_Number_New__c,Or_contact_Name__c,Or_contact_Phone__c,Or_contact_Email__c,Or_contact_Fax__C,Account_Name__c,Contact_Name__c,Phone__c,Fax__c,Email__c,Bill_To_Street__c,Bill_To_City__c,Bill_To_State_Province__c,Bill_To_Zip_Postal_Code__c,CreatedById,Bill_To_Country__c from Quote__c where id =: ApexPages.CurrentPage().getParameters().get('Id') ];
  id=q.Account_name__c;
     } 
    public pageReference Save(){ 
     quoteId=ApexPages.CurrentPage().getParameters().get('id');    
    quote__c qu= new quote__c();
    qu.id=quoteId;
    qu.Or_customer_PO_Number__c=customerponumber;
      If(test != NULL && test != '')
    {qu.Or_customerid__c=test;}
    else
    {qu.Or_customerid__c=q.Account_Code__c;}
       If(test1 != NULL && test1 != '')
    {qu.Or_Account_name__c=test1;}
    else
    {qu.Or_Account_name__c=q.QSA_Name__c;}
    If(test19 != NULL && test19 != '')
    {qu.Or_invoiceadd1__c=test19;}
    else
    {qu.Or_invoiceadd1__c=q.Bill_To_Street__c;}
        If(test3 != NULL && test3 != '')
    {qu.Or_invoiceadd2__c=test3;}
    else
    {qu.Or_invoiceadd2__c=q.Bill_To_State_Province__c ;}
        If(test6 != NULL && test6 != '')
    {qu.Or_invoiceadd3__c=test6;}
    else
    {qu.Or_invoiceadd3__c=q.Bill_To_Zip_Postal_Code__c ;}
        If(test9 != NULL && test9 != '')
    {qu.Or_invoiceadd4__c=test9;}
    else
    {qu.Or_invoiceadd4__c=q.Bill_To_City__c;}
        If(test12 != NULL && test12 != '')
    {qu.Or_invoiceadd5__c=test12;}
    else
    {qu.Or_invoiceadd5__c=q.Bill_To_Country__c;}

     qu.Or_contact_Phone__c=q.Or_contact_Phone__c;
     qu.Or_contact_Name__c=q.Or_contact_Name__c;
     qu.Or_contact_Fax__c=q.Or_contact_Fax__c;
     qu.Or_contact_Email__c=q.Or_contact_Email__c;
     qu.Or_Carrier__c=Carrier;
     qu.Or_orderdate__c=orderdate;
     update qu;

    return null;
    }  
       public void valueToConInfo(){
   conId=q.Or_contact_Name__c;
        if(conId!=NULL) {
            cont=[Select name,phone,Fax,Email from Contact where id=:conId];
            if(cont!=null){
                if(cont.Phone!=null || cont.Phone!=''){
                    q.Or_contact_Phone__c=cont.phone;
                }if(cont.Email!= null ||cont.Email!=''){
                    q.Or_contact_Email__c=cont.Email;
                }if(cont.Fax !=null || cont.Fax!=''){
                  q.Or_contact_Fax__c=cont.Fax;
                }
            }
        }
   }
} 

If inputputtext is null then it get the value and save in object. And in case if value is there it will show in that inputtextbox .

In case they want to update the value they can write new one it has to save in object.

currently it is getting value and showing the value it is not updating the new value.

1 Answer 1

2

You are not referencing the variable from your controller.

Try: <apex:inputtext value="{!qu.Or_customer_PO_Number__c}" ... />

Note the qu variable is referenced rather than Quote__c.

Update:

In your constructor you're setting the q variable to your existing quote. So in order to display the existing value on the page you need to reference q.Or_customer_PO_Number__c in your VF page.

Now onto your save method, if someone changes the value, you want to be able to save that value to your quote. At the moment, every time you call the save method, you are creating new quote instance and setting it's ID to the existing one (that you loaded previously):

quote__c qu= new quote__c();
qu.id=quoteId;
qu.Or_customer_PO_Number__c=customerponumber;

You can either continue working with the same q variable instead of creating a new one every time, or alternatively you can keep your code and set the qu.Or_Customer_PO_Number__c = q.Or_customer_PO_Number__c since that's now the field displayed on the page.

2
  • no not accepting Error: Unknown property 'Quote__cStandardController.qu
    – Teja
    Commented Aug 8, 2014 at 5:18
  • Can you please update your question with more code of your controller? I am not able to see what's going on there. Commented Aug 8, 2014 at 5:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .