Hello, I would like to know if there is possibility of creating a task scheduler programmatically and how to do it, without having to go through the administration menu.
Thanks and regards.
Hello,
Cuba has no API to create scheduled tasks from code, but there is an ability to add them right to the database by query.
Scheduled tasks are presented in SYS_SCHEDULED_TASK table.
There is an appropriate way to simplify the script development:
- Open Administration - Scheduled Tasks menu
- Create the required scheduled task.
- In the Scheduled Tasks table, find the task and click on it by the right button
- Select the âSystem Informationâ item
- There on the bottom of âSystem Informationâ dialog find âScript for insertâ button
- Click on it and the corresponding SQL becomes available.
- Now it is possible to copy it.
So that SQL may be programmatically added to database scripts (UPDATE SCRIPTS or INIT DATA: 30.create-db.sql)
It may be also run at any time as a native query (see [url=https://doc.cuba-platform.com/manual-6.1/nativeQuery.html?_ga=1.18911101.474659065.1458115059]https://doc.cuba-platform.com/manual-6.1/nativeQuery.html[/url])
If you really want to create tasks at runtime, you can also create and save ScheduledTask entities. It will be the same as creating tasks in UI.
Thanks Rostislav
Thanks Konstantin.
true
Please tell me how to create a CUBA task Scheduled