Hello everyone, I have an issue with uploading a file into a database.The select file settings are shown belowBelow is the upload button logic.
Here is the logic of the server action shown above
And this is the errorJust to inform, I have gone through 3 same questions and tried the solution but apparently I am still stuck. Also, I am trying to implement the best practice which is to show the server action inside the client action. I am quite confuse with how actually does the server action inside the server action works because I haven't found any videos on explaining that. I also read the documentation which I don't understand.May somebody explain to me what actually is the problem?
Hi @Hazim Jamal ,
As I see your action, is that you do assign after CreateOrUpdateFile_DSP1?
You need to do assignment before saving File_DSP1.
Anw, can you show what do you pass as input of CreateOrUpdateFile_DSP1 in the action?
Regards,
Khuong
ProjectID is primary here, So you might have already a record there.So the solution is, Add a new column (Id) and make it as Primary key( Set as Identifier) and confirm once that ProjectID is not selected as unique key under entity property.
I don't understand, the PROJECTID, in FILEDSP is an identifier of another entity.And 1 Project would have 1 File called DSP.Hence the one to one relationship between Project Entity and FileDSP entity.Why would I want to make a new column to make a new Primary key?
Ok. In this case, Before inserting a record you need to check if ProjectID is already exist, If yes update or else create it. Add this check
Hi Hazim,
Unfortunately, you do not show the full error message, so it's difficult to pinpoint exactly what the problem is. However, judging the part that's visible, the UploadFile entity has a mandatory ProjectId attribute that's a foreign key into the Project entity. And when you create or updaet the UploadFile entity, you do not set the value of ProjectId, so it's NullIdentifier(), which is not a valid value if an Id is mandatory.
Hye Killian, thank you for your response. Below is the full error message.
And on top of that, I would like to ask if my database is correct or even practicing the best way because I tried practicing the best way but it seems to make it harder when connecting the database to the front end side which I suppose leads to this kind of error.To explain this database and why I did it. Talking about the static entity to entity relationship. I did the one to many relationship because For example, One Project Status (Static Entity) can connect to many Projects & 1 Project (Normal Entity) can connect to one project status (Static Entity). Hence the 1-to-many relationship. I suppose it is the right way to do so.Talking about the Uploadfile EntityFor Example,
1 Project can have 1 FileSP (A type of file). Hence why the Identifier of each of those 4 entities on the right side of the picture, is an identifier of a Project.Talking about the ProjectImportantPeople, It's a many to many since 1 Project can have many project managers and 1 project manager can have many Projects. Hence the Many to many relationship and the extra table. Which I've learnt is right.
The problem that I find is the uploadfile, since in my database later on when wanting to create aggregates, makes it a little difficult to understand. Would you mind explaining about this part.
As my understanding, the error occurs because there is no project id value as you are assign to your FileDSP1.ProjectId in the Project table.
For example: you want to assign FileDSP1.ProjectID = 2 but in Project table the Project.ProjectID = 2 does not existed.
To solve your upload, I think you first save your Project table and get the newly created Project.ProjectID value and assign to your FileDSP1.ProjectID then save your FileDSP1.
Hye, how do I assign the newly created Project.ProjectID value to the FileDSP1.ProjectID?Because I have already save the project in a previous page.
As you have already save the project mean that you have ProjectID value right?
You can get the ProjectID from CreateProject or CreateOrUpdateProject actions under Project Entity. Then you can play with this value such as pass as Input parameter to your Upload page...
Hye @Khuong,In this here, how would I connect the ProjectID to this input parameter?
I'm still getting the same error, what part am I missing at?
Please check my comment above.
Hye I'm sorry, I am very clueless. I don't see to understand what's happening
Can U share your oml, If possible remove sensitive things and share a separate one?
Hello @Khuong Truong,Terribly sorry for the late reply, I have now found the solution thank you.Regards,Hazim