Use variable to filter aggregate

Use variable to filter aggregate

  

I have an Aggregate in an Action. 

Based on the value of an Action's Input Variable, I want to be able to filter the aggregate.

This way I will avoid creating multiple Aggregates based on the value of the Input Variable.

Is this possible? How can I do this?


Thanks a lot


Marios 

Hello Mario,

You can use variables directly into an aggregate (if the aggregates can "see" the variable based on its scope).
This is shown in the online training...

Beware using aggregates in "Server actions", as the optimization will be shutting down if you return from it the list of the aggregate, as the platform can't know beforehand where the action will be used.

Cheers.

Hi Marios,

What content is the action input variable going to have? It's possible, depending on what you need.

Depending on the input you have, you can use advanced queries to do more advanced operations.

Regards,

Thanks, Eduardo,


I want to use a filter variable, in which I will create a condition for the Aggragate Filter based on the Input Variable. 

And then, use the filter variable in the aggregate filter.


 

Marios Tofarides wrote:

Thanks, Eduardo,


I want to use a filter variable, in which I will create a condition for the Aggragate Filter based on the Input Variable. 

And then, use the filter variable in the aggregate filter.


 

In general, yes, you can do it without problem.
Are you new to Aggregates?

If so, I recommend you to take a look in the online training to get familizarized with it, and check the online documentation that Marco pointed.

An aggregate can have filters and in the filters (as well as in the join clauses), you can use "external" variables (declared in the page or in the action the aggregate is).

Cheers.


Eduardo and Marco,


I've done aggregated before, but not dynamic filters in an aggregate. I'll check what you posted.


thanks a lot!


Marios

Hi Marios,

You can do the dynamic filter using variable in aggregate like below where EmployeeNumber is InputParameter of action.




Regards

-SK-

Shashi, 


What I really want is to put that expression into an "EmployeeFilter" variable and then just type in the filter "EmployeeFilter"


Marios

Marios Tofarides wrote:

Shashi, 


What I really want is to put that expression into an "EmployeeFilter" variable and then just type in the filter "EmployeeFilter"


Marios

Hello Marios,

You can't do that in an Aggregate.
For this type of "dynamic" filter, you will need a SQL statement, passing the condition as a Query parameter (set to expand inline).
But if you will give the user the ability to write the condition freely, I think he will also be able to inject SQL.

Cheers.


OK Eduardo,


Thanks a lot. I might try that. 


Marios