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
Linda 98Linda 98 

help on else if statements with OR operator.

My question might be silly but i am missing something which i am not able to figure it out.
I am having various if,else if statments in my apex class.

which i had written like below.For some reason OR (||) operator is not functioning as expected.
please correct me what am i missing.
if((opp.stagename =='aaa' || opp.stagename=='bbb') && (opp.Description == null ||
    opp.Rate__c == null || opp.Due_Date__c == null)) {
                 system.debug('ENTER IN TO IF');
               }
else if((opp.stagename=='ccc' || opp.Stagename =='ddd') && (Opp.Description ==null ||   opp.Rate__c ==null || opp.Due_Date__c ==null)){
                        system.debug('ENTER IN TO ELSEIF');
}
else if(opp.stagename == 'eee' || opp.stagename =='fff'  || opp.stagename=='ggg' ||
           Opp.stagename == 'hhh' || Opp.StageName == 'Closed Lost' || opp.StageName == 'Closed Won'){ 
        system.debug('ENTER IN TO 2nd ELSEIF')      
  //  THIS IS WHERE I AM FAILING.EVEN THE STATEMENTS IS FALSE,ITS ENTERING TO ELSE IF INSTEAD OF ELSE.rEST ALL WORKS FINE.
         }
 else{ 
// another logic here.
     }



Thank you in advance!
Ashish_Sharma_DEVSFDCAshish_Sharma_DEVSFDC
Could you please paste error message ?
Linda 98Linda 98
No error message ashish.But even though else if conditions are not true,its going inside that loop and displaying ENTER IN TO 2nd elseif debug.
It has to go to else statements.
Ashish_Sharma_DEVSFDCAshish_Sharma_DEVSFDC
Please check your data using debug statements as it can not enter there without meeting criteria.
saikat sarkarsaikat sarkar
What are the value of 
1. stagename
2. Description 
3. Rate__c 
4. Due_Date__c 
that you are using for the testing?
Linda 98Linda 98
I checked everything but still its entering in to loop instead of else.
Linda 98Linda 98
Sounds weird but i deleted entire clas and created new class ,copy paste th code,..its working. Thank you