SugarCRM / SuiteCRM – Adding created_by and modified_user_id using SugarBean

If you are a big fan of using SugarBean to handle CRUD (Create Read Update Delete) operations, you might have noticed that the created_by and modified_user_id values are automatically provided by the underlying code logic. You can bypass this logic and override the UserIDs. Below is the example PHP code:

$bean->set_created_by = false;
$bean->update_modified_by = false;
$bean->created_by = "uuid-of-the-user";
$bean->modified_user_id = "uuid-of-the-user";
$bean->assigned_user_id = "uuid-of-the-user";

Also, SugarBean automatically provides the date_entered and date_modified values. Use the following if you’d like to override them.

$bean->date_entered = "Y-m-d H:i:s";
$bean->date_modified = "Y-m-d H:i:s";
$bean->update_date_entered = false;
$bean->update_date_modified = false;