The INSERT statement conflicted with the FOREIGN KEY constraint


Hey Guys, So I'm getting this error, just like a lot of other folks. I have read legitimately every single post on the forum on how to solve this issue, but I still can't figure it out. Mind you, I KNOW what the problem is, just not how to fix it. Would you be ever so kind as to giving me a step by step solution? (Yap, I realise this is didactic and a learning exercise. I'm only asking this because most of the answers on the threads are you need to do this and that, but I don't know how to this nor that..). 

The App im building is a retake on the ToDo app assignment, on which I had the same error and wasn't able to fix it.

Best regards,

Fran :)

Hello Fran,

I took a look at the application, could you please tell me at what point you are getting the error?  I also see it depends on Core, which is not uploaded - do you know if the error is from the Patients eSpace or from the Core eSpace?

Lastly, did you check the error log and details in ServiceCenter?  It provides much more information than what you get on the screen.

Thank you

Solution

That error occurs because, the forein key PatientInfoId is setted as mandatory. In your form you dont retrieve this fileld, which means that you will try to create a record with a null value on the patientInfoId and the database return that error. 

To solve it you must either set Retrive the patientInfoId on the form, set it programatically, or go to the core espace and set the field as optional. 

Solution

Craig St.Jean wrote:

Hello Fran,

I took a look at the application, could you please tell me at what point you are getting the error?  I also see it depends on Core, which is not uploaded - do you know if the error is from the Patients eSpace or from the Core eSpace?

Lastly, did you check the error log and details in ServiceCenter?  It provides much more information than what you get on the screen.

Thank you


Thank you Craig, sorted it thanks to Domingues!

Domingues wrote:

That error occurs because, the forein key PatientInfoId is setted as mandatory. In your form you dont retrieve this fileld, which means that you will try to create a record with a null value on the patientInfoId and the database return that error. 

To solve it you must either set Retrive the patientInfoId on the form, set it programatically, or go to the core espace and set the field as optional. 


I hope you find a 100 dollar/Euro/Pounds/whatever bill on floor. thank you so much