Hi guys I'm a new developer here I am having a problem with deleting test user in outsystems whenever I delete test user an error occurs. This always happens.
@Axcel Guarda ,
Find the below post that Already share solution.
https://www.outsystems.com/forums/discussion/33746/insert-statement-conflicted-with-the-foreign-key-constraint/
https://www.outsystems.com/forums/discussion/47144/the-insert-statement-conflicted-with-the-foreign-key-constraint/
Hpoe this will help you.
Hi Axcel,
You mentioned that this error occurs when you're deleting a test user. However, the error shown above is related when creating a new record in the UserExtend entity using an invalid UserId, such as 0.
Could you clarify the flow of this action causing the error?
Hi @Axcel Guarda,
You mentioned that you're encountering this error during user deletion, but typically, this error indicates a database constraint violation—most likely due to an attempt to insert a record without supplying a required UserId value.
Please debug the flow to verify whether the UserId is being set to 0 during the insert operation. Additionally, investigate the delete flow to ensure that the UserId is correctly passed when the delete button is clicked.
Hope this helps.
Thankyou
It seems that some logic is running after the user deletion that might be trying to insert data into UserExtend entity using the deleted user’s ID which is causing the foreign key violation. Can you please share the .oml file. So it will be easier to look it your problem and give you solution.
Thanks,
Sriyamini.J
@Axcel Guarda : Based on the log file, it looks like the error occurs on the signup page (https://personal-wqh6wusa.outsystemscloud.com/PalayProtectorApp/Signup) when someone tries to register. I was able to reproduce the issue using sample data.
The issue is that the user isn’t getting created successfully, and without checking the result of that operation, the flow tries to insert a record into the UserExtended entity. Since the user creation fails, it returns a null UserId, and I assume UserExtended has a one-to-one relationship with the User entity.
Attaching a debugger should help you identify the root cause and fix it.
Hi @Axcel Guarda ,
Please have a look to the below link first and try to understand the delete rule among your user & user_extend entity.
https://success.outsystems.com/documentation/10/developing_an_application/use_data/data_modeling/entity_relationships/delete_rules/
I am not sure about your delete logic or query you are using to delete the user but I believe you need to first delete the user from child entities like user_extend and then you need to delete the user from user entity if relationship is protected.
Regards,
Manish Jawla