I would believe that this is because you refer to a field name that ends with “_c” which is fed from the a custom table.
the associated custom field table (to the original one ) is not always populated and if no fields is to be entered in those studio created fields then the actual record is not created in the custom table, which ends to an empty variable…
try to use the actual case_number field instead…
like $acase_case_number notice no _c