You need to sign in to do that
Don't have an account?
Anime Lover
How to use string expression in IF condition Apex
Hi there,
I am stuck in my program, Actually I want to use String expression into the IF statement condition.
eg:
Is there any solution for this, Please let me know your thoughts on this.
Thanks,
Rahul
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
What is the value you are trying to keep in expression1?
below is the if condition check for string.
If(!IsEmpty(expression1 ))
Regards,
Ankaiah
As I can see you are passing string value in if condition, but If-else only accepts boolean value.
So, please try the given code below.
I hope you find the above solution helpful. If it does, please mark it as Best Answer to help others too.
Thanks and Regards,
Suraj Tripathi
I have set above account Industry value to Energy but I am always getting FALSE value to my debug state ment
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);
}