Database Id is repeating with new entered data

Hi all,As I am adding new category(Add Category) it is replacing with the same CategoryId.How can I solve this.See the .oml attached

OnlineShop.oml

Solution

Hello Parveen, I cannot execute your module. there is a core and I cannot do anything. But lets

Try to do this

1-Create a variable with Category Data Type

2-Instead of the aggregate put the form with the source of the local variable

 and fix the inputs


3-When saving, on the action save. Change the aggregate and put the record from the form


Let me know if I helped you

Kind regards,

Márcio

Thank you for the help. It works.

mvp_badge
MVP

Hi Parveen,

Apart from the solution provided by Marcio, you need to understand what happens. Each Entity in OutSystems has associated Create, CreateOrUpdate and Update Entity Actions (which should actually be abstracted by CRUD actions, but that's an advanced topic). If you use the Create Entity Action, always a new record will be added to the database, with a new unique Id (at least for default Entities that have an auto number Id). If you use CreateOrUpdate, it depends on whether the Id of the record you pass is filled: if it is NullIdentifier(), a new record will be created, if the Id is a value other than NullIdentifier(), the existing record will be updated. If you use tje Update Entity Action, you need to provide the Id of an existing record.

With the above knowledge you may be able to infer why your original code went wrong (I haven't looked at it, no time at the moment).

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.