30
Views
20
Comments
Solved
Data form duplicates when updating it

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:

mvp_badge
MVP
Rank: #73
Solution

Samed Gurses wrote:

i sent you a private massage, but i dont think you can download the .OML there.

Here you have it 

 Hi Samed,

Thank you for sharing the .oml file with us. I have checked the code and refactored a lot of implementation within the AanvraagDetail Screen/client action as well as within, most of the associated Server action logics.

I would suggest you to thoroughly check all the code changes which I made in the shared .oml or else the better way is to replace the complete screen and the associated server actions implementation to the Original module from the uploaded .oml file. Before checking the implementation (i.e. after publishing the code changes) make sure that you delete all the Entity (Gegevens & GegevensFoto) records by accessing the Test Screen (just by clicking the DeleteAllDBData button

Please check the attached updated .oml file.


Hope this helps you!


Regards,

Benjith Sam

FM.oml

Rank: #6929

Benjith Sam wrote:

Samed Gurses wrote:

i sent you a private massage, but i dont think you can download the .OML there.

Here you have it 

 Hi Samed,

Thank you for sharing the .oml file with us. I have checked the code and refactored a lot of implementation within the AanvraagDetail Screen/client action as well as within, most of the associated Server action logics.

I would suggest you to thoroughly check all the code changes which I made in the shared .oml or else the better way is to replace the complete screen and the associated server actions implementation to the Original module from the uploaded .oml file. Before checking the implementation (i.e. after publishing the code changes) make sure that you delete all the Entity (Gegevens & GegevensFoto) records by accessing the Test Screen (just by clicking the DeleteAllDBData button

Please check the attached updated .oml file.


Hope this helps you!


Regards,

Benjith Sam

 

 Hi Benjith,


First i thank you for your effort. The issue is solved with your help, but now if have this problem: when i want to upload a image into a form i get the following error (when i click "wijziging opslaan" button):


Rank: #21948

In the update action you are not making a create instead of updating the record? Duplication is because when you update you are creating a new user and not updating the existing one.

mvp_badge
MVP
Rank: #73

Hi Samed,

As per the shared information, I assume that for storing the User Images i.e. multiple Images for a single User, the drafted data model would be one to many relationship type between the UserMasterEntity and UserImageEntity (1-N Relationship type)


- Is it that you are using the CreateOrUpdateUserMasterEntity action anywhere within the SaveIt or Opslaan action flow (while administrator is adding multiple/single image to a specific user's record)

If is it so, then make sure that the passed UserMasterEntity.Id value to the respective CreateOrUpdate Entity action must be a not null value, if the passed UserMasterEntity.Id = Null then a new record will be created instead of update, hence you will observe duplicate record in the UserMasterEntity table

- Note that the CreateOrUpdate Entity action does have both capability i.e. To Create a new record or else to update a record existing in the Entity, so the create/update action is basically decided on the basis of the SourceRecord.Id value..

If SourcRecord.Id = Null ---> New Record will be created

If SourceRecord.Id <> Null ---> Respective record will get updated with modified value


If the above mentioned description is not helping you to solve the issue, If possible could you please share the .oml file with us to help you better.


Regards,

Benjith Sam

Rank: #6929

Benjith Sam wrote:

Hi Samed,

As per the shared information, I assume that for storing the User Images i.e. multiple Images for a single User, the drafted data model would be one to many relationship type between the UserMasterEntity and UserImageEntity (1-N Relationship type)


- Is it that you are using the CreateOrUpdateUserMasterEntity action anywhere within the SaveIt or Opslaan action flow (while administrator is adding multiple/single image to a specific user's record)

If is it so, then make sure that the passed UserMasterEntity.Id value to the respective CreateOrUpdate Entity action must be a not null value, if the passed UserMasterEntity.Id = Null then a new record will be created instead of update, hence you will observe duplicate record in the UserMasterEntity table

- Note that the CreateOrUpdate Entity action does have both capability i.e. To Create a new record or else to update a record existing in the Entity, so the create/update action is basically decided on the basis of the SourceRecord.Id value..

If SourcRecord.Id = Null ---> New Record will be created

If SourceRecord.Id <> Null ---> Respective record will get updated with modified value


If the above mentioned description is not helping you to solve the issue, If possible could you please share the .oml file with us to help you better.


Regards,

Benjith Sam

 Hi Benjith,


I am new to outsystems so i do not really know what you mean by CreateOrUpdateMasterEntity. This is how my diagram looks like:


And this is how my Opslaan action looks like:


Here is the assign i use:



To improve performance, i merged both update/createOrUpdate for Gegevens and Foto's (images) into 1 action called Opslaan.

If you still dont have enough details, I think it's good to share the OML file  with you, let me pls know,


Cheers

 

mvp_badge
MVP
Rank: #73

Hi Samed,

It is because you are trying to add an Image before creating the User record in that specific request

i.e. the input parameter GegevensId = NullIdentifier() which is passed in the GegvensFoto record creation and as the GegevenId (FK) is a mandatory Field defined in the GegvensFoto Entity, it raised an ForeignKey constraint DB Exception


 Do a small change, wrap the  "wijziging opslaan" button within an IF control with the below mentioned condition

GegevensId <> NullIdentifier()

See the attached .oml file


Regards,

Benjith Sam

FM.oml

Rank: #6929

Benjith Sam wrote:

Hi Samed,

It is because you are trying to add an Image before creating the User record in that specific request

i.e. the input parameter GegevensId = NullIdentifier() which is passed in the GegvensFoto record creation and as the GegevenId (FK) is a mandatory Field defined in the GegvensFoto Entity, it raised an ForeignKey constraint DB Exception


 Do a small change, wrap the  "wijziging opslaan" button within an IF control with the below mentioned condition

GegevensId <> NullIdentifier()

See the attached .oml file


Regards,

Benjith Sam

 

 Hi Benjith, I have antoher question :)

Now when i upload i image it works, but it is not visible on the users form list, and also not visible on the managers list with forms. I tried to change the expression, but it still wont show the uploaded image. I solve the previous error with changing 1 entity from mandotory "yes" to "no"

mvp_badge
MVP
Rank: #73

Hi Samed, 

You don't have to change the GegevenId (FK)  (GegvensFoto Entity) attribute mandatory  property from "yes" to "no"  instead wrap the  "wijziging opslaan" button within an IF control with the below mentioned condition

GegevensId <> NullIdentifier()

as shared in the last attached .oml file

and after form submit please check whether the binary data is successfully getting stored in the GegvensFoto - FotoBinary attribute by right clicking the GegvensFoto entity and clicking the view option

If still facing the problem share the latest .oml file


Regards,

Benjith Sam

Rank: #6929

Benjith Sam wrote:

Hi Samed, 

You don't have to change the GegevenId (FK)  (GegvensFoto Entity) attribute mandatory  property from "yes" to "no"  instead wrap the  "wijziging opslaan" button within an IF control with the below mentioned condition

GegevensId <> NullIdentifier()

as shared in the last attached .oml file

and after form submit please check whether the binary data is successfully getting stored in the GegvensFoto - FotoBinary attribute by right clicking the GegvensFoto entity and clicking the view option

If still facing the problem share the latest .oml file


Regards,

Benjith Sam

 

 I uploaded a image and there is a attribute in the Entity (see the .OML):


FM2.oml

mvp_badge
MVP
Rank: #73

Hi Samed,

The uploaded image is not visible on the users form list and also in the managers list with forms because the GegevenId is set with 0 value on the creation of new Record in the GegevensFoto entity

Please change the GegevenId (FK)  (GegvensFoto Entity) attribute mandatory  property from "no" to "yes" 

and b

Before checking the implementation (i.e. after publishing the code changes) make sure that you delete all the Entity (Gegevens & GegevensFoto) records by accessing the Test Screen (just by clicking the DeleteAllDBData button)

see the attached .oml file

Hope this helps you!


Regards,

Benjith Sam

FM.oml

Rank: #6929

Benjith Sam wrote:

Hi Samed,

The uploaded image is not visible on the users form list and also in the managers list with forms because the GegevenId is set with 0 value on the creation of new Record in the GegevensFoto entity

Please change the GegevenId (FK)  (GegvensFoto Entity) attribute mandatory  property from "no" to "yes" 

and b

Before checking the implementation (i.e. after publishing the code changes) make sure that you delete all the Entity (Gegevens & GegevensFoto) records by accessing the Test Screen (just by clicking the DeleteAllDBData button)

see the attached .oml file

Hope this helps you!


Regards,

Benjith Sam

 

 Hi Benjith,


Is this the right way of the IF statement (the second IF statement on picture)? Or do you mean enclosing it with a IF. Because if this is the IF you mean, the error still occurs. 

mvp_badge
MVP
Rank: #73

Hi Samed,

I'm not confused with the requirement, I guess maybe I was unable to properly explain the implementation... the below mentioned pointer is what I want you to implement

1) Don't wrap the Wijziging opslaan button within the IF widget, I do understand the usage of that particular button (Did Google Translate!)

2) Instead Wrap the Foto opslaan button within the IF widget using the below condition

GegevensId <> NullIdentifier()

- The below Widget structure is what it looks after implementing the above mentioned points..

Hope this helps you!


Regards,

Benjith Sam

Rank: #6929

Benjith Sam wrote:

Hi Samed,

I'm not confused with the requirement, I guess maybe I was unable to properly explain the implementation... the below mentioned pointer is what I want you to implement

1) Don't wrap the Wijziging opslaan button within the IF widget, I do understand the usage of that particular button (Did Google Translate!)

2) Instead Wrap the Foto opslaan button within the IF widget using the below condition

GegevensId <> NullIdentifier()

- The below Widget structure is what it looks after implementing the above mentioned points..

Hope this helps you!


Regards,

Benjith Sam

 

 Hi Benjith, i allready have removed the IF in the action. And allready have the same settings as your picture: 

But what i do not understand is that this only a UI change. But the problem is with the gegevens.ID. And the problem is with the "Wijziging opslaan" button. That is what is confusing me.

Thank you

mvp_badge
MVP
Rank: #73

Ok Samed,

Finally, I traced the issue which you got encountered with.. sorry for the loop :)

- Just Include an additional assignment statement within the assignment node, defined in SaveGegevensFoto Server action as shown below

Please refer the attached updated .oml file

Hope this helps you!


Regards,

Benjith Sam

FM.oml

Rank: #6929

Benjith Sam wrote:

Ok Samed,

Finally, I traced the issue which you got encountered with.. sorry for the loop :)

- Just Include an additional assignment statement within the assignment node, defined in SaveGegevensFoto Server action as shown below

Please refer the attached updated .oml file

Hope this helps you!


Regards,

Benjith Sam

 

 Hello Benjith,


This was the problem! And this was also the solution :) Thank you bro. After long time we finally managed to fix the problem. Thank you very much for you help and effort, I appreciate it!