Hi, and welcome to another Tech Bite.
In this tech bite, we will demonstrate how to set timers to delete records and use an online store as an example.
In the app, we have an entity called Shopping Cart Items, where we save all the items each user is interested in buying.
To clear all the shopping carts nightly, we will create a server action Delete All Cart Items.
Add a SQL node to the server action and write the necessary query to delete all records from that entity. In this case, despite Delete queries not having outputs, every SQL node needs an output structure or entity. Thus we use a dummy output.
Next, we’re recording in the system log that the action was completed. Add a Run Server Action to the flow and select the system action Log Message. Add its attributes, Message and Module Name. The recorded message will appear in the OutSystems Service Center logs.
Finally, we will create a timer on the processes Tab to run every night. Create a Timer Action Clear Carts that invokes the previously created server Action—Delete All Cart Items— which occurs Daily at 4 in the morning.
Now we’re ready to publish. You can check the Service Center logs the morning after to ensure the timer ran as expected.
Thanks and see you on our next Tech Bite!