AnsweredAssumed Answered

SugarCRM v6.5 anything after $bean->save stops working

Question asked by Rodolfo Tuble on Feb 9, 2017
Latest reply on Feb 9, 2017 by Rodolfo Tuble

I have this code:

function saveField($field, $id, $module, $value)
{

$bean = BeanFactory::getBean($module, $id);

if (is_object($bean) && $bean->id != "") {

if ($bean->field_defs[$field]['type'] == "multienum") {
$bean->$field = encodeMultienumValue($value);
}else if ($bean->field_defs[$field]['type'] == "relate" || $bean->field_defs[$field]['type'] == 'parent'){
$save_field = $bean->field_defs[$field]['id_name'];
$bean->$save_field = $value;
if ($bean->field_defs[$field]['type'] == 'parent') {
$bean->parent_type = $_REQUEST['parent_type'];
$bean->fill_in_additional_parent_fields(); // get up to date parent info as need it to display name
}
}else{
$bean->$field = $value;
}
//return here will work
$bean->save(); //this works
//nothing works here
return getDisplayValue($bean, $field);
} else {
return false;
}

}

The problem here is that anything under

$bean->save()

will not work. But I know that save is working as the values are being updated. So how can I debug this problem?

I already tried:

return var_dump($bean->save());
return print_r($bean->save());
if($bean->save()){
return "1";
}else{
return "2";
}

And none of those in the above worked I still get nothing in my return.

Outcomes