In some situations, we need to show specific data in a table row or a list item that might not be directly related to the data we are using on the aggregate.
In our example, we work with products, names, prices, and shopping lists. We also know which products were bought and how many units.
Each table row represents one entry on the shopping list. Products can appear many times depending on who bought them. However, what if we want to flag the products purchased over one hundred units, no matter who bought them?
Can we go to the "get products by id" aggregate and get that information? Unlikely, since it'll probably affect the output unexpectedly.
Should we fetch that data using a "data action"? No, because we can't run a "data action" for each row!
Additionally, that flag shouldn't be placed directly in the table cell.
Instead, we should create a new Block.
Right-click on the MainFlow, choose “Add Block”, and name it. This new block can then safely be placed inside the table cell without any issues arising later on that can affect the app's good functioning.
Next, let’s create the block’s input parameter to specify data for each block instance. Name it as "product Id", representing the product to be passed on from the aggregate.
On the block, right-click on “Fetch Data From Database” to create a new aggregate.
Drag the Entity “Shopping List” and go to the Tab Filter on the top left-hand side.
Click “Add Filter” and, on the filter Condition window, filter the Shopping list by "product id".
Back at the main window, right-click on the attribute “Quantity” and get the "sum function" of all units.
Back in our Block, drag and drop an “if widget”.
Set the “If Condition” logic to fetch the Sum Quantity attribute we got in the previous step and compare it to one hundred.
Finally, drag the flag icon to the true clause of the If the condition.
After publishing and running our app, we now see that we have two products: books and spoons. But only the books were bought more than one hundred times!
When including forms in applications, developers often wonder if they need to re-validate data on the server side after having checked it on the client. Why go to the trouble of checking the data twice?
When developing an OutSystems reactive web app, you would expect to display data quickly, but it doesn't always happen. Do you know why? We'll explore the reasons and how to tackle them.
Did you know that the OutSystems Platform has tens of screen templates to help you quickly put together your apps? Let me show you how you can use them.