The INSERT statement conflicted with the FOREIGN KEY constraint

The INSERT statement conflicted with the FOREIGN KEY constraint

  

The INSERT statement conflicted with the FOREIGN KEY constraint "OSFRK_OSUSR_6LM_REQUEST2_OSSYS_USER_REQUESTER". The conflict occurred in database "CGBDHT029", table "dbo.ossys_User", column 'ID'. The statement has been terminated.


But the user exists in my database

Hi Daniela, it's hard to analyze without knowing data your are using but it does seem that's an error of either passing null in the Requestor field or passing a non-existant Id, is it happening in your bootstrap action or in the NewCRF screen?


Have you tried debugging to see which values are actually being passed onto the create action?

Solution

Hello Daniela,

This error means that ou are trying to create a record in the entity, but this entity (Request) has a mandatory Foreign Key (Requester) that (most probably) is not being provided, or the value provided does not match one in the User entity.

In what screen and on which action is this happen?

I'm inclined to the error happening in the Bootstrap, and the user with id 2 do not exist in the database (you can view data to check it). In the Save action where you use the form to save a Request, it seems to be everything fine.

Cheers

Solution