How can I make an aggregate return the number of records dynamically based on an input parameter 'MaxRecord'?
So if 'MaxRecord' is 100, the aggregate will return 100 records.
If 'MaxRecord' is 0, it will return all record.
Currently, I do it by having 2 aggregates and assignments. An 'if' operator determines which aggregate and assignment to call.
Also, there is no value of Max. Records that will guarantee you get all records, but you can set it to a very large value like "1000000000" which in practice is enough to fetch all. Something like "if(NumRecords = 0, 1000000000, NumRecords)".
The attribute for max. records in the aggregate can be filled with an variable...
Stefano Valente wrote:
Hi Stefano
I am aware of this property. But was wondering if it can return
- maxrec number of records
- all records if maxrec is a certain value
Kai Ming Thia wrote:
You can get the number of records of the query and the number of records returned. Its the difference between aggregate.list.length and aggregate.count.
Not sure if this is what you asked...
Hi Kai,
You can set value of the Max. Records property to a local an input or local parameter of data type Integer, as well to any other expression that returns an integer value. Click on the arrow on the right of the property to either set the parameter or open the expression editor.
Regards,
Daniel
Daniël Kuhlmann wrote:
Hi Daniel
What if i want all records? What should the Max Records be?
Currently, it will return all records if Max Records is not set.
Kilian gave you the answer.
@Stefano: you shouldn't tell novice developers about the Count Property. One should never use it, only with care, since it will execute another query!
That said, my answer was already marked as Solution, so let's close this topic.