I have a variable that successfully holds the result from a query in a trigger. I am able to use this variable to update the Contact record. However; if the query does not return records the variable is not assigned any value. I can't seem to test that the variable is blank and assign it a placeholder value.
How can I test the value of ExecEdCustomerSEMCODE when no records are returned and no value is assigned?
Thanks,
Kevin
// Most Recent Contact ExecEd SEM Code string ExecEdCustomerSEMCODE;
ExecEdCustomerSEMCODE = [select SEM_Code__c from Interaction__c
WHERE Contact__c = :record.Contact__c AND SEM_Code__c != null
ORDER BY Start_Date_Time__c DESC LIMIT 1].SEM_Code__c;
if (String.isBlank(ExecEdCustomerSEMCODE)){
ExecEdCustomerSEMCODE = 'test-blank';
}