530
Views
8
Comments
Solved
How to update only single attribute using aggregates ?
Application Type
Traditional Web

How to update only single attribute using aggregates ?

Like We can use SQL Tool for updating only single attribute for a record  , How to do it using Aggregates  instead of Sql tool? 


2022-07-22 08-49-20
Laura Fidalgo
Solution

Any time!

Aggregates work in a different way: they retrieve data, they don't have write actions. So you need to use the entity actions and, for that, yes you have to mention all attributes. You can't provide just one attribute, it won't work. You need to provide the entire record, including of course the one that changed.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Solution

Aggregates are for data retrieval only, not for modifying data, so either SQL or the Entity Actions need to be used. Do note that when updating via SQL you probably need to do some trickery to know if the update succeeded - the Entity Actions will throw an exception if update did not succeed.

2022-07-22 08-49-20
Laura Fidalgo

Hi @Vishal Gangwal ,

You can't use aggregates directly to update records, you'll need to use the entity actions for that. 

So you'll need to create a flow that gets the record you want to update, assign that new value you want to change, and use the entity action to update the record with the new value.

Hope this helps!

UserImage.jpg
Vishal Gangwal

Thank you for your reply. Right , but if I want to update only single attribute say quantity using entity action update"entityname" , is it possible like sql ? In entity action we have to mention all the attributes.

2022-07-22 08-49-20
Laura Fidalgo
Solution

Any time!

Aggregates work in a different way: they retrieve data, they don't have write actions. So you need to use the entity actions and, for that, yes you have to mention all attributes. You can't provide just one attribute, it won't work. You need to provide the entire record, including of course the one that changed.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

You cannot do that without an SQL, but then again, you'll in most cases already have the full record you just read from the database, so you can just change the one attribute, then save it.

2025-09-29 11-10-28
José Alexandre dos Santos

Hi Vishal,

Hope to find you well

The only way I seen to update an atribute using aggregates, in a non prod environment of course, is to access the module where the enitity were created then:
Double click on the entity;
Filter for the record you want to update;
Click at the specific atribute;
Change the value;
Click apply;

PS: You can also add a new record (insert).

Cheers,

JS.

UserImage.jpg
Vishal Gangwal

Thank you all. 

My requirement  was like if the user changes the product quantity to order then the stock of that product should decrease by that much quantity in other table accordingly. For this I am using SQL tool in multiple situations and it is working fine. 

But as I was going through forum , came to know that Aggregate is more efficient than SQL tool. So that's why Checked if it is possible to do that using Aggregate.

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Solution

Aggregates are for data retrieval only, not for modifying data, so either SQL or the Entity Actions need to be used. Do note that when updating via SQL you probably need to do some trickery to know if the update succeeded - the Entity Actions will throw an exception if update did not succeed.

2022-07-22 08-49-20
Laura Fidalgo

Aggregates are more efficient than sql queries to retrieve data, because outsystems can optimize performance automatically. But you can't write on the DB with aggregates :) 

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