I am using a delegate class to set the value of 3 fields in my record before the record is saved. The code reads the previous values for these 3 fields and sets them back to their prior values under certain cirumstances.
The problem is that the code always gets the wrong DB record. It gets the first record every time which is not the correct one. What am I doing wrong?
- Code: Select all
function beforeSave(&$record){
$db_rec = df_get_record('change_memos', array('change_memo_id'=>$record->val('change_memo_id')));
if ($db_rec){
$record->setValue('last_steps', $db_rec->val('last_steps'));
$record->setValue('last_reminded', $db_rec->val('last_reminded'));
if ($record->val('workflow_id') == ""){
$record->setValue('workflow_id', $db_rec->val('workflow_id'));
}
}
}