The INSERT statement conflicted with the FOREIGN KEY constraint "OSFRK_OSUSR_71O_PASS

The INSERT statement conflicted with the FOREIGN KEY constraint "OSFRK_OSUSR_71O_PASS

  

hi,

please explain the meaning of this error and i wanted to save the comment in the input box when the save action is performed  after save button is clicked but I am getting the above error.The comment is not getting save in the entity.

I have two entities Comment which having (comment and PassengerId) and Passenger entity .

I want to save the Comment and aftr clicking the particular passenger that comment should be present there.

1st page:

 2nd page:

3rd page:


4th page:


Please someone help to resolve this issue.


Thanks

Akanksha Pandey wrote:

hi,

please explain the meaning of this error and i wanted to save the comment in the input box when the save action is performed  after save button is clicked but I am getting the above error.The comment is not getting save in the entity.

I have two entities Comment which having (comment and PassengerId) and Passenger entity .

I want to save the Comment and aftr clicking the particular passenger that comment should be present there.

1st page:

 2nd page:

3rd page:


4th page:


Please someone help to resolve this issue.


Thanks

You have to assign the PassengerId to the PassengerComment record being created :)


Hello, just to expand the answer given by José.

Every record in your entity Comment needs to know to which record in the entity Passenger it is related. So you created a Foreign Key (FK) in it, called PassengerId, and defined that it is mandatory (and this makes sense).

As this FK is Mandatory, in the moment you want to create a new record in the Comment entity, you need to provide to which passenger this comment is associated. You probably have the PassengerId input parameter, as this seems to be a DETAIL page, that has this value. So, before SAVING (Create or CreateOrUpdate action) in the action that saves this record into database, you need to add an Assign node and set the PassengerId attribute of the record you are using to store the comment.

If you don't provide a value, the database will accuse an error because it will try to locate in table Passenger the ID, that is not being provided, and will not find it.

I imagine that this Comment entity is an extension of the entity Passenger (the Primary Key is of type PassengerId), as it seems that only a single comment can be entered.

Cheers.

P.S. 

You CAN'T save a comment BEFORE creating a new Passenger.
And if it is a NEW passenger, even after you create it, the value in PassengerId (the input parameter) will still be zero.

So, you have to guarantee that no comments can be added to the passenger before it is created, and guarantee that the input parameter PassengerId is updated with the ID returned by the CreateOrUpdate action that saves a new record in Passenger.

Cheers.

Eduardo Jauch wrote:

P.S. 

You CAN'T save a comment BEFORE creating a new Passenger.
And if it is a NEW passenger, even after you create it, the value in PassengerId (the input parameter) will still be zero.

So, you have to guarantee that no comments can be added to the passenger before it is created, and guarantee that the input parameter PassengerId is updated with the ID returned by the CreateOrUpdate action that saves a new record in Passenger.

Cheers.


How can I guarantee that no comments can be added to the passenger before it is created and guarantee that the input parameter PassengerId is updated with the ID returned by the CreateOrUpdate action that saves a new record in Passenger?

Hi,

In the action that saves the comment, you can check if the PassengerId is different than NullIdentifier().
You can also use an IF in the screen and show the comment area ONLY if the PassengerId is different the NULL().

I recommend the Online training, as all this is shown there.

Cheers.

José Lopes wrote:

Akanksha Pandey wrote:

hi,

please explain the meaning of this error and i wanted to save the comment in the input box when the save action is performed  after save button is clicked but I am getting the above error.The comment is not getting save in the entity.

I have two entities Comment which having (comment and PassengerId) and Passenger entity .

I want to save the Comment and aftr clicking the particular passenger that comment should be present there.

1st page:

 2nd page:

3rd page:


4th page:


Please someone help to resolve this issue.


Thanks

You have to assign the PassengerId to the PassengerComment record being created :)


I have already done but itsnot comming. The error is there.


Please solve this issue.


Hi Ankita,

As Eduardo suggested, you first need to check whether your PassengerId is NULL or not.
If its NULL, you should first insert Passenger Details and then after getting PassengerId you can update PassengerComment.

So in your method, while saving comment, please check whether your passenger is already crated or not.
If not, create it first and then add comment.

Regards,
Palak