I am writing a trigger that has an IF clause based off of a field. However, I cannot get it to recognize if that picklist is blank. I have tried:
field.isblank()
string.isblank(field)
field == ''
field == '--None--'
field == NULL
None of these catch when there is no value. Prior to saving the record, the field says 'deleted' if I set it to –none–…but I'm not sure how to check that value within a trigger.
Thank you!
Best Answer
A picklist is essentially a string. For a string, you want to test using
isEmpty() == true
. That covers''
andnull
. If you have a--none--
you want to test against, you'll want to also add that specifically to your conditions if that's an optional value included in your picklist. If so, use a boolean||
.