Duplicated entry when saving new record

HI.

I made a module file type with module builder.

I created and deleted some records without problem, but lately when i create a new record the screens stay blank.

I check the log file and shows me the message:


Wed Aug 16 23:28:16 2017 [3184][1][ERROR] upload_file could not copy [ upload://736ab890-ca04-d171-8128-59935026c193 ] to [ upload://bc92fd4e-b7fc-beb4-90ce-59951b93e3ca ]
Wed Aug 16 23:28:17 2017 [3184][1][FATAL] Error inserting into table: your_module: Query Failed: INSERT INTO your_module (id,date_entered,date_modified,modified_user_id,created_by,deleted,filename, .... )
VALUES ('bc92fd4e-b7fc-beb4-90ce-59951b93e3ca','2017-08-17 04:28:16','2017-08-17 04:28:16','1','1',0,'','2017-08-16', .....): MySQL error 1062: Duplicate entry 'bc92fd4e-b7fc-beb4-90ce-59951b93e3ca' for key 'PRIMARY'
Wed Aug 16 23:28:17 2017 [3184][1][FATAL] Exception in Controller ....

So, it seems to be a problem with some duplicated key records but i though SuiteCRM assigns by itself, so, what can i do to this?

Thanks.

In the module i have a Logic Hook with after_save.
In the function of the logic_hook i made some calculations with the fields that are registered, in the end i save the bean with the resut of calculations.

$bean->save();

Commenting that line the page continue with the detail view but the calculations are not made.

Maybe you can try to delete that row giving the error directly in the database, and see if it’s just a transient error. Maybe it won’t happen again.

That INSERT, you didn’t write that yourself, or did you? Is it SuiteCRM code?

That happens in all records of that module., so, the id is always different.

That insert is in SuiteCRM Code

Hi,

http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.9/Architecture/Logic_Hooks/Module_Hooks/after_save/

Considerations

Calling save on the bean in this hook will cause an infinite loop if not handled correctly. (i.e: $bean->save())

:wink:

1 Like