Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.
Hi there,

I am stuck in my program, Actually I want to use String expression into the IF statement condition.

eg:

String expression1 = 'Annual_Rev__c != 0 && Status__c == "Closed"';

if(expression1 ){

System.debug('It Worked...!');

}

Is there any solution for this, Please let me know your thoughts on this.

Thanks,

Rahul​​​​​​​
4 answers
  1. Dec 12, 2021, 12:51 PM
    Hi  Ankaiah  

    usually, we use any Boolean expression in the if(Condition)  like If(Acc.Industry == 'Software') but can we put the condition into the string variable and use that variable to IF() condition like

    String expression1 = 'Acc.Industry == 'Software';

    if(expression1){

    System.debug(true);

    }
Loading
0/9000