function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
d.tejdeep@nicomatic.ind.tejdeep@nicomatic.in 

Only one condition is working?

<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:inputtext value="{!test}" /></td>
              </tr>
<apex:commandButton value="Save" action="{!Save}"/>

controller:

public class createorder {
    public List<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 Today { get { return Date.today(); }}
    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 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')];
       }
   
    public pageReference Save(){
    // q  =[select id,Customer_PO_number__c,Account_name__c,Account_Name__r.Account_Code__c,order_date__c,requested_date__c,comment__c,Carrier__c from Quote__c where id=:Apexpages.currentPage().getParameters().get('Id')];
       
       // update q;      
    quoteId=ApexPages.CurrentPage().getParameters().get('id');
    quote__c q=[select id,Account_Code__c from quote__C where id=:quoteid];
    quote__c qu= new quote__c();
    qu.id=q.id;
    qu.Customer_PO_number__c=customerponumber;
   qu.Carrier__c=Carrier;
    qu.order_date__c=date.today();
    qu.comment__c=comment;
    If(test==NULL){
    qu.Test_field__c=test;}
    else{
    qu.test_field__c=qu.Account_Code__c;}

    update qu;
    update q1;
    return null;
    }
         
In this one condition is working every  but not both .

I want that if value not there at text box qu.test_field__c=qu.Account_Code__c;
I want that if value there in textbox qu.tex_field__c=test;

why it is not taking two condition ?

Any other way?
}
Jean-NoelJean-Noel
You have your condition in reverse, currently it's like that
If there is no value in test, qu.test_field__c = test;
If there is a value qu.test_field__c=qu.Account_Code__c;

If(test != NULL && test != "")
{
    qu.Test_field__c=test;
}
else
{
    qu.test_field__c=qu.Account_Code__c;
}