Save record using beans but created_by field not get added in CRM DB

Hi team,

I save record using $bean->save(); method and update using bean. When i do that in audit table id, parent_id, date_created, field_name, data_type, before_value_string, after_value_string, before_value_text, after_value_text get added but created_by field is NULL. Do you have any solution. Thanks in advance :slightly_smiling_face:

Hi @morevishal,

Where are you saving from?

have you tried to assign value to $bean->created_by before the save?

If you are saving from a LogicHook, use the following code to assign the current user. Code should be added before saving the bean:

global $current_user;
$bean->created_by = $current_user->id;

Thanks,

BrozTechnologies

Thank you Broz Technologies I save data using Entry Point I tried there
global $current_user;
$bean->created_by = $current_user->id;
but still it’s not working

Not sure if you have to invoke some files in a entry point.

Please check these samples. In some the user uses current_user :https://github.com/audoxcl/SugarCRMEntryPoints

Thanks,

BrozTechnologies