the insert statement conflicted with the foreign key constraint

the insert statement conflicted with the foreign key constraint

  

hi im trying to create a like client action that doesnt even notify a user that their post is liked and the user who posted cant even see who liked but they can see its liked .so i created all server actions and everything when i tried testing it ,it brings this message up..the insert statement conflicted with the foreign key constraint "OSFRK_OSUSR_RRC_REACTIONLIKE_OSUSR_RRC_REACTION_REACTIONID"""" column ID. the statement has been terminated...can you please help me solve this action i would really only like for users to like with no consent who did it and when ....thank you

Hi MUSGADO


You're trying to insert a database record that has a null value on a mandatory field. For a bit more help we need to see the logic flow and the values you're assigning to the created record


Regards,

   CLSJ

Hi MUSGADO,


Could you provide more information or screenshot.


-Vijay M-


hey guys i think this is what you asking for...?

Hi Musgado,

The message basically means, like Carlos mentioned, that when you are writing your entity record to the database, you forgot to assign a mandatory reference attribute/foreign key a value, so it holds NULL and the database complains that is not valid.

In this particular case, it seems that when you call the CreateStatusLike entity action, you forgot to assign to the StatusLike record the ActivityId it relates to.

thanks uhm let me try to fix this i will get back to you as soon as possible

im so confused..how do i fix this then

problem with this is that it can easily let another user who is not the one who created the status be able to like the status and comment but the original user cannot do both...i get that you guys understand the error but my problem is going around to fix this that you say i have forgotten to put in this action...im a slow learner so please bare with me

how do i  assign to the StatusLike record the ActivityId it relates to?.

hey Mr jorge 

i just realised that when i test how outstagram works it actually does the same error...check out the component outstagram and post an image with it then try to like the image you posted and comment on it ,it will give you the same error...can you please check it out you probably will get me easeir on what im struggling on its a similar situation. thank you https://www.outsystems.com/forge/component/2266/outstagram/

It seems ok, but what is your create_activity actually do?

does it give an id back?

furthermoe can you provide an oml, because it might something obvious.

this the oml with actions the same as mine...go to server actions "create" and you will see the create postLike action then see how things are...thank you for the response Mr j i'll be waiting to hear from you...thanks 

Hi,


your create_activity is the issue.

1. the first thing you do is checking if the "TargetUserId = GetUserId()", 

if that is the case, you are not creating the activity and thus returning a null.

2. you continue without checking, so you will try to insert/update a status with a activityId = null.

3. boom

  

thanks let me try that i will get back to you ...thank you very much