+ Start a Discussion
MaheemSamMaheemSam 

Not able to use || OR operator in IF condition

Hi, 

 I want to use a || (OR) operator condition inside the code But I get error Error: Compile Error: unexpected token: '||' at line ​

  
Please suggest me how to add with multiple add and or condition in the if statement
public PageReference  ApprovalpageAction(){
   if ( SPRProcheck > 0 &&
        P_SPR_Approver_Director <> NULL && 
        P_SPR_Approver_RVP <> NULL && 
        P_SPR_Approver_GVP <> NULL && 
        P_SPR_Approver_EVP <> NULL && 
        Olicheck > 0 && Athcheck > 0 &&
        UsrNFRcheck == 0 ) || ( UsrNFRcheck == 1)
     {
       Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
       req.setObjectId(PageID);
       Approval.ProcessResult result = Approval.process(req);
       //redirectpage();
      PageReference acctPage;
      acctPage = new ApexPages.StandardController(new SPR__c(id=PageID)).view();
      acctPage.setRedirect(true);
      return acctPage; 
     }
   else if ( 
           SPRProcheck > 0 && 
           P_SPR_Approver_Director <> NULL && 
           P_SPR_Approver_RVP <> NULL && 
           P_SPR_Approver_GVP <> NULL && 
           P_SPR_Approver_EVP <> NULL && 
           Olicheck == 0 && 
           UsrNFRcheck == 0 )
     {
       Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
       req.setObjectId(PageID);
       Approval.ProcessResult result = Approval.process(req);
       //redirectpage();
      PageReference acctPage;
      acctPage = new ApexPages.StandardController(new SPR__c(id=PageID)).view();
      acctPage.setRedirect(true);
      return acctPage; 
     } 
   else if ( SPRProcheck > 0 && 
             P_SPR_Approver_Director <> NULL && 
             P_SPR_Approver_RVP <> NULL && 
             P_SPR_Approver_GVP <> NULL && 
             P_SPR_Approver_EVP <> NULL && 
             UsrNFRcheck == 1 && OppNFRcheck == 1 && 
             P_DitiDiscountcheck == 100  )
     {
       Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
       req.setObjectId(PageID);
       Approval.ProcessResult result = Approval.process(req);
       //redirectpage();
      PageReference acctPage;
      acctPage = new ApexPages.StandardController(new SPR__c(id=PageID)).view();
      acctPage.setRedirect(true);
      return acctPage; 
     }   
    return redirectpage();  
 }


Thanks

Sudhir

deepak balur 19deepak balur 19
Can you try if ( ( SPRProcheck > 0 &&
    P_SPR_Approver_Director <> NULL &&
 P_SPR_Approver_RVP <> NULL &&
 P_SPR_Approver_GVP <> NULL &&
 P_SPR_Approver_EVP <> NULL &&
 Olicheck > 0 && Athcheck > 0 &&
 UsrNFRcheck == 0 ) || ( UsrNFRcheck == 1) )
MaheemSamMaheemSam
Thanks that worked let me test all the condition in the code and see if it working as expected
deepak balur 19deepak balur 19
OK, Please mark this as the best answer for future references...Thanks