You need to sign in to do that
Don't have an account?
Simrin
Any suggestions and reason for cause, if known ?
If condition check for blank space
public with sharing class Controller1{ public String temp1 {get;set;} public String temp2 {get;set;} public void test() { //temp1 ='someValue' and temp2='SomeValu1' if(temp1 != '' && temp1 != null && temp2 != '' && temp2 != null){ //Manipulation } } }I had above piece of code, which checked if condition properly, but when i moved code to Sandbox, the if condition always fails.
Any suggestions and reason for cause, if known ?
Best Answer chosen by Simrin
kevin lam
I'm not sure why it fails in your sandbox but I always use the isBlank or isEmpty methods:
- String.isBlank(temp1) - returns true if the string is not whitespace, not empty (''), and not null.
- String.isEmpty(temp1) - returns true if the string is empty ('') or null.