Good morning! I would like to ask for help to find out if it is possible to create a crontab with nodejs in wappler.
For example, I need to record a 3-month recurrence. When the 3 months are up, make an insert in the bank again.
Thanks in advance.
Good morning! I would like to ask for help to find out if it is possible to create a crontab with nodejs in wappler.
For example, I need to record a 3-month recurrence. When the 3 months are up, make an insert in the bank again.
Thanks in advance.
Hi,
A crontab in Wappler is called a scheduled task.
I don't guarantee you'll understand what I say next, but I'll try anyway:
You create a scheduled task to run e.g. every hour to generate whatever you want. Don't schedule to run every 3 months, no one does that.
The important thing to understand is, you should make the task "idempotent", meaning if you run it multiple times it won't mess up your data. This could be achieved by checking the date of the last recurrence, so it only runs after 3 months.
I understood. My question in this case is how to use wappler components correctly.
This recurrence is generated using a form, and this is later saved in the database.
However, the recurrence time is variable. The user can define a week, a month, a quarter and so on.
My question is how to do this and especially how to make it dynamic
Hey, as mentioned by Apple, you can either give user a choice or create a rule that would determine recurrence timeline, that is up to you, and save it inside database. You can then create scheduled task, with condition that would check whether the recurrance_day from your database == today, and it would run your selected action. Now, whether you need to daily or hourly preccision, you would simply run the scheduled action every hour, etc. checkign whether the recurrance_date <= now