13
Views
13
Comments
Solved
Dubble data in list when updating

I have a form that users can fill in and save it, a manager can open the received forms saved by the normal users. Than the manager can add images and select dropdown choices and save it.

And i have a list for users where they can see the forms they saved and filled. So whenever now a manager add a image or selects a dropdown choice, the data will be dubbled, so if the manager for example adds a image, and the normal users goes to the list of his filled in forms, he will see the 2 forms, one with image and one without image. The same problem when the manager selects a dropdown choice. 

And the strange thing is, when you update it for the first time, like when you upload a image for the first time and save it, it just updates. But when you for exmaple open the same form again and this time you select a dropdown choice and save it again, it than dubbles the form on the users dashboard


The first form filled in:


Now i added via the manager role and manager dashboard a image to this form, and now on the user dashboard with filled in forms, it is dubbled:




The button for updating via the manager dashboard:

Rank: #8765
Solution

Maria da Graça Peixoto wrote:

In the action, are you assigning any thing to it?  

GegevensFoto local variable in your action have no information when you call it. You are assigning the Id from the Gegevens record, and the binary data , but if you already have a photo in a record you have to assign the Id of that record to GegevensFoto.Id also, to tell the system that you want update that existing record. 



 the latest image show the Opslaan action, as you see i allready have a assign:

 

i do not have other actions/assigns than this 

Hi! 

Perhaps you are saving the image only with a "Create.." action and not a "CreateOrUpdate..." action. 

Just an idea. 

Regards

Graça

If the aggregate is giving 2 records at least one of the entities have a duplicate record.

 Have you tried to see which one? 

That will help you to pinpoint the "CreateOrUpdate..." that is missing the correct Id field when the record already exists.

Just use the "view data" option in the entities. 

I think you are forgetting to get the "GegevensFoto.Id" from query when a photo is already in the database. 

I don't see that field anywhere,  

In the widget "CreateOrUpdateGegevensFoto " you have in the Opslaan action. 

Probably the Id field is empty, it should have a variable that holds nullIdentifier() if the record is new or the "GegevensFoto.Id" from query when a photo is already in the database.    

Samed, you should review the courses in the path 

https://www.outsystems.com/learn/paths/2/becoming-a-traditional-web-developer/

Hope have helped. 

Graça 

In the action, are you assigning any thing to it?  

GegevensFoto local variable in your action have no information when you call it. You are assigning the Id from the Gegevens record, and the binary data , but if you already have a photo in a record you have to assign the Id of that record to GegevensFoto.Id also, to tell the system that you want update that existing record. 



Actions in the "logic" tab are pieces of independent code and when called have all the local and output variables empty, to use them we must assign the values we want to use, to them. 

So you are not assigning it Samed. !!!!

Just add a new one in that widget, probably you will need (I don't know if it is there already it is not in the images) a new parameter in the action to get the Id from the screen action.

 in the Variable you put   GegevensFoto.Id  

in the Value you put the parameter that have the Id you get in the query in the "GetGegevensById.List.Current.GegevensFoto.Id field.