Refresh Aggregate

Refresh Aggregate

  

i have externally append a list in preparation's aggregate in a screen action. After appending the list ,i am refreshing it and the whole list get jargoned. I want whole list to be the same as i append after refresh.

What i am doing wrong?

Hello Lovish,

If you append a list to the aggregate list, you are adding items to the aggregate list.
If later on, you refresh the aggregate, this means that you will execute it again, and its list will be reseted (cleaned) and filled again with database data.

This means that any appends you have made will be lost.

The only way to keep them is to add them again, what will have to be done in the Screen Action where the refresh is being done and this will cause performance issues.

So, the big question here is: Why do you need to append items to the result of the aggregate?
What is your use case?

Depending on your use case, we can provide you with better alternatives.

Cheers,
Eduardo Jauch

Eduardo Jauch wrote:

Hello Lovish,

If you append a list to the aggregate list, you are adding items to the aggregate list.
If later on, you refresh the aggregate, this means that you will execute it again, and its list will be reseted (cleaned) and filled again with database data.

This means that any appends you have made will be lost.

The only way to keep them is to add them again, what will have to be done in the Screen Action where the refresh is being done and this will cause performance issues.

So, the big question here is: Why do you need to append items to the result of the aggregate?
What is your use case?

Depending on your use case, we can provide you with better alternatives.

Cheers,
Eduardo Jauch

hi ed, 

The aggregate list i have used in table to show result. Their is search logic implemented . After searching i want result to be rearranged in a particular manner. for that i have used 1 extra list and i am emptying the aggregate list and append that customized list . after appending the list, i am refreshing the aggregate . The moment i refresh the aggregate i am loosing the order of value. I want to maintain the order as it is in that appended list. So how to do this. I have to show the result in table only . For that i have to apply ajax refresh on table container. Is their any better way to persist that appended list in table

Hi Lovish,

First, let me ask you something... 

Why do you need to order the aggregate list output outside the aggregate itself? I know of some cases where this is necessary, but most of the time it is possible to order inside the aggregate/sql.

Said that, if you are executing the aggregate in the preparation, than you are ordering the results in a new list, you can provide this list (being a screen variable) as source to the table records.

Here, I think using the aggregate or the list will be the same thing.
in both cases, you don't need to refresh the aggregate after the ordering.

If you are doing this in a Screen Action, you also don't need to refresh the aggregate AFTER you ordered the results. Just an Ajax Refresh to the Table Records will suffice, as it will look for the ACTUAL data in its source, being the aggregate list or the local list.

In any case, doing this will impact negativelly in the applications performance...

Cheers,
Eduardo Jauch

Eduardo Jauch wrote:

Hi Lovish,

First, let me ask you something... 

Why do you need to order the aggregate list output outside the aggregate itself? I know of some cases where this is necessary, but most of the time it is possible to order inside the aggregate/sql.

Said that, if you are executing the aggregate in the preparation, than you are ordering the results in a new list, you can provide this list (being a screen variable) as source to the table records.

Here, I think using the aggregate or the list will be the same thing.
in both cases, you don't need to refresh the aggregate after the ordering.

If you are doing this in a Screen Action, you also don't need to refresh the aggregate AFTER you ordered the results. Just an Ajax Refresh to the Table Records will suffice, as it will look for the ACTUAL data in its source, being the aggregate list or the local list.

In any case, doing this will impact negativelly in the applications performance...

Cheers,
Eduardo Jauch


actually earlier i have used preparation list in table and i had applied searching logic. After searching i want some elements at top and others are at bottom. For that i have created a list and i am appending that list in preparation list after clearing it. After append, i have to apply the record refresh. The moment i applied the record refresh it again distort the order of the list which i append. 


The other way i am doing is taking the result of preparation in local variable list and assign it to table. So during searching the other list which i made while adjusting the order of the element according to the requirement and appending it to the local list variable. So when i applied ajax refresh to table  that local list becomes empty. 


So explain me the both scenario what wrong i am doing? And then suggest me right way to maintain the ordering of that appended list. So that its ordering wont get distorted after ajax refresh to a table

I already told you.

You CAN'T refresh the aggregate just AFTER you order its list.
When you refresh an aggregate, it CLEAR its list (erase everything) and fetch data again.

About the local list, I would have to take a look into your code to know what is going on.

Cheers,
Eduardo Jauch 

Eduardo Jauch wrote:

I already told you.

You CAN'T refresh the aggregate just AFTER you order its list.
When you refresh an aggregate, it CLEAR its list (erase everything) and fetch data again.

About the local list, I would have to take a look into your code to know what is going on.

Cheers,
Eduardo Jauch 


Present in ManageCOUGGroups. when we search the result I want to show the contents of My Groups first and then the rest of groups

Hello Lovish,

I started to look to your code, but today is sunday and your code seems a little bit complex to see fast, so, instead, based on what you said, that you want to keep a group of records at the top all the time (something like my groups between all groups), I am sending you a small oml with an example on how to do it.

Basically, you create a new column in the aggregate, where you set an expression that will "order" (starting from 0) your data. In the example, I want all the items with group id of 3 to be at the top of the list, all the time (don't use hard coded IDs, ok?), so, I just put an expression comparing with it and if true, the order is 0, otherwise, the order is 1.

After that, I add a new sort to the list of sorts, at the first position, using the new column, like this :

This will make my list, no matter how it is ordered, keep the items I chosed to be always at the top, allowing me to use the aggregate as it is, without any extra logic.

You can test it here: https://eduardojauch.outsystemscloud.com/FilterWithGroupAlwaysAtTop/Home.aspx?_ts=636509508306235960

Hope it will help you with your problem.

Cheers,
Eduardo Jauch

this seems to be better solution edurado. But I have many group id. Here you are comparing only 3. I am getting My Groups id from first aggregate of preparation and i have to compare all the id's . If any one is matched then i can assign it to 0 else 1. Is there ANY operator so that i can compare ,let suppose{2,3,4,5} . if any one matches then it set it to 0 else 1. if not then how to achieve this. I mean My group id's are not constant always. it may be 2 elements , may be 5 or may be 0 element. is there any method for ex: 

if(id={mygroupidlist},0,1)

Hi Lovish,

How do you define which groups should be "first", and whose should be after those?

Cheers,
Eduardo Jauch

the group id's present in first aggregate in the preparation. Actually i have maintain 2 aggregate , one for my group and other for all group. the search logic is applied only for All group. Your way is right . I just wonder why outsystem doesnt have IN operator for aggregate , so that i can compare if(id IN {2,4,6}, 0 , 1). The other way is to maintain if else ladder , like If(id = 2,0, if(id=3,0, if( id=5,0,1))). But i cant write 2,3,5 . I have to represent them like 

id=list[index]  or if their is any way i can do if(id= {list},0,1)

Hum...

In your case, you are probably better doing an advanced query (sql), passing those IDs in an inline parameter to use in an IN clause...

Probably is possible to merge those two queries in an aggregate (I already did something similar), but the query will be less confusing...

Cheers,

Eduardo Jauch

QUESTION

How do you define which records will be in the result of the first aggregate?

Lovish Goyal wrote:

this seems to be better solution edurado. But I have many group id. Here you are comparing only 3. I am getting My Groups id from first aggregate of preparation and i have to compare all the id's . If any one is matched then i can assign it to 0 else 1. Is there ANY operator so that i can compare ,let suppose{2,3,4,5} . if any one matches then it set it to 0 else 1. if not then how to achieve this. I mean My group id's are not constant always. it may be 2 elements , may be 5 or may be 0 element. is there any method for ex: 

if(id={mygroupidlist},0,1)

Hi Lovish,

Like Eduardo said, for this kind of scenario, Aggregates will not be helpful, you will have to use a SQL statement and the NOT IN keyword. Also, if you do this, for performance reasons it is strongly suggested you get rid of the first Aggregate and instead use an inner query directly on the SQL statement.