Filter Server action doesnt seem to be working

Hi, im creating a reactive web app on version 11.8.7.

In the Final Plan screen. i am running a client action to create the final plan for a student course plan. On the first call of a client action (create plan) is when the aggregate is fetched. this then clears a whole bunch of aggregates and enters another client action which is where im having trouble. 

I need to find a way to only input a number of records (which is decided by the user) into these aggregates. I have a large aggregate with all of these courses in it, so i need to filter out this aggregate so only the courses that run at certain times are run through a foreach loop to assign these courses to a new aggregate that have been cleared for the semester and that year. 

then i need to remove the courses from there filtered lists so they do not get repeated in another semester aggregate. 

However the Filter server action, seems to not recognise the condition at all and either prints all values or, in the second filter case, no values at all. 

I am not sure why the filter isnt recognising the condition or if there is a better way of doing this. 

Attached is the OML, thanks in advance 

PS i know there is alot of random code in other clients, but these arnt being used, ive been trying to figure this one out for a while. the problem with the filters is in "PlanCreate" client action.


Hi Mitchel,

I don't know where to start. You clear aggregates. That doesn't make sense, and should not be done. The aggregate data is fetched by OutSystems. If it fetches more records then you want you need to enter the filter criteria on the aggregate.

If you, after filtering an aggregate using the filter tab on the aggregate definition still need to additionally create a list, then define that list as a local variable, and either

1) loop over the aggregate list <aggregatename>.List witha foreach and use IF widgets to conditionally add the current aggregate record to the list, or

2) Use ListFilter, but this has limited possibilities in filtering.

Furthermore I think you have to redesign your datamodel, the CourseId attributes have the wrong data type and have no relationship to the Course table.


Regards,

Daniel

Daniël Kuhlmann wrote:

Hi Mitchel,

I don't know where to start. You clear aggregates. That doesn't make sense, and should not be done. The aggregate data is fetched by OutSystems. If it fetches more records then you want you need to enter the filter criteria on the aggregate.

If you, after filtering an aggregate using the filter tab on the aggregate definition still need to additionally create a list, then define that list as a local variable, and either

1) loop over the aggregate list <aggregatename>.List witha foreach and use IF widgets to conditionally add the current aggregate record to the list, or

2) Use ListFilter, but this has limited possibilities in filtering.

Furthermore I think you have to redesign your datamodel, the CourseId attributes have the wrong data type and have no relationship to the Course table.


Regards,

Daniel

 Hi Daniel, 

I know about the aggregates, i have been avoiding changing them all over too variables for a while now but i have done it now. I understand my data model is incorrect, i have been looking into it and will implement changes if i have time. 

For now though, i am trying to do option 1 that you have suggested, but using the debugger i have found that in the first iteration, it simply assigns the entire list, regardless of the condition. The If statement works fine as it only reaches the assignment widget if the condition is met, but once the assignment widget is reached, the entire list is assigned to the variable instead of the record that the iteration is currently at. The same thing is happening with the ListFilter. 

How can i fix this issue? this is in the "Plan Create" action 

thanks Daniel, i apologise if the code is a bit all over the place, im no expert at outsystems haha

Regards Mitchell.