CreateOrUpdate Entity is not creating but only updating the table

Hello,

I'm a newbie to Outsystems. I'm trying to create an application where I can upload the files in one page and display the same in another. I'm using the CreateOrUpdate Entity to do the same. But every time I upload a new file it is overwriting on the old and not creating a new one. I also noticed that the ID has not changed, hence this is happening. How do I fix it?

Thanks in advance,

Madhu

Solution

Madhu K wrote:

Hello,

I'm a newbie to Outsystems. I'm trying to create an application where I can upload the files in one page and display the same in another. I'm using the CreateOrUpdate Entity to do the same. But every time I upload a new file it is overwriting on the old and not creating a new one. I also noticed that the ID has not changed, hence this is happening. How do I fix it?

Thanks in advance,

Madhu

Hello Madhu,

To create something in the DB with CreateOrUpdate you must garantee that ID is NULL.

Everytime you pass an ID to CreateOrUpdate the platform will update it.

Solution

Hi Madhu,

 If you use a CreateOrUpdate action to add a new record make sure to assign NullIdentifier() to the Id attribute of the entity record that you want to add.

Alternatively you could also use the Create action of the entity. In that case you do not need to set the Id attribute to NullIdentifier().

Regards,

Daniel

Thanks a lot!

It helped.