Timeline for Check lookup field is null in apex
Current License: CC BY-SA 3.0
3 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 20, 2018 at 13:47 | comment | added | Schnaps | But when checking for null you will get unwanted behaviour, when the Id is empty. A way to produce an empty Id is with sObject.put(String fieldname, String value) method. Try the following in exec anonymous: Account s = new Account(); System.debug(s.Id); if(s.Id == null) System.debug('check for null ok.'); s.put('Id',''); if(s.Id == null) System.debug('check for null ok.'); if(String.isBlank(s.Id)) System.debug('check for isBlank ok.'); System.debug(s.Id); | |
Feb 21, 2016 at 17:00 | vote | accept | Prajith | ||
Feb 19, 2016 at 14:56 | history | answered | Adrian Larson♦ | CC BY-SA 3.0 |