16
Views
13
Comments
How do I update entity data with the Update server action?
Application Type
Traditional Web

I'm trying to set up my bootstrap so that it updates the entity if it's not empty, and creates the entity if it is. I added the update action in the false flow, and the action says that it replaces all the attributes in the entity record, but when I run this nothing happens. Am I using update incorrectly? Do I need to use a different action?


Rank: #446

Hi Joseph,

First, I would like to advise you to please try to debug the flow of this action and find where the control is going after List empty check? Also, it might be the case that you are not getting the list empty and it is going to true condition and not creating any new record since that set of records already exist, if there is any index setup on that entity.

If possible for you please share the OML with us to find the exact cause.

Thanks & Kind Regards,

Sachin

Rank: #70

Hi Joseph,


You need some kind of key to identify the record you want to update or if you want to create a new one.

Something like in this image, where you check first if it exists the record in the database (in the example, I'm checking by Nomination attribute). The CreateOrUpdate will create a new record if Id is null (doesn't exist already) and update if the id is not null (in the case it exists a Trend with that Nomination):


OML in attachment.


Hope it helps.


Regards,
João

AwardsVoting.oml

Rank: #446

Could you please confirm why you are using the Bootstrap action? Just to update the data into the entity? IF so, there is a already default entity action named as CreateorUpdate which can be used to update in case if record already exist or to insert the new record. Please refer the below link to get more details about BootStrap.

https://success.outsystems.com/Documentation/How-to_Guides/Data/How_to_update_a_Bootstrap_Action_to_fetch_an_entity_identifier_from_Excel