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