The Scheduled tasks node is used to work with scheduled tasks – events which are scheduled to be executed at certain intervals. Scheduled tasks are used for a variety of features, e.g. rebuilding indexes, scheduling emails, or running integration activities.
Solutions are born with a set of system tasks, but you can also create new scheduled tasks on a need-to basis:
- Click + New task
- Specify a name
- Select a begin time and (optionally) an end time
- Set a repetition interval – e.g. 5 minutes or 1 hour
- Save and open the newly added Task to add one or more Subtasks to it
In DynamicWeb 10 a scheduled task can contain several Subtasks of which there are two types:
- Add-in subtasks that trigger a default or custom add-in
- Activity subtasks that run an integration activity
Scheduled task add-ins
DynamicWeb ships with a default set of add-ins for scheduling particular kinds of actions – they are listed in the table below:
| Add-in | Used for |
|---|---|
| Assign products to one or more groups, depending on some rules | |
| Build Ecommerce Assortment items | Rebuilds assortments |
| Build repository index | Rebuilds a repository index |
| Calculate users segment search results | Recalculates user segment searches |
| Clean up login log | Deletes login audit log entries older than the configured retention period |
| Cleanup logs | Cleaning up logfiles |
| Cleanup missing digital assets | Removes references to digital assets not found from products |
| Digital assets checkin on products | automatically assigns assets to asset categories |
| Deploy data items from upload folder | Deploys deployment packages |
| Discontinue products by date | Marks products as discontinued once their Discontinued by date has passed |
| Email Marketing Flow Scheduler | Triggers email marketing flows |
| Execute method from Assembly | |
| Feed File Export Task | Saves Feed-data to a file |
| Place recurring orders | Places subscription orders |
| Product version cleanup | Automatically purges old versioning data |
| Product Email Notification Addin | Sends out email notifications based on product queries |
| Redeem expired points | Removes expired loyalty points from user accounts |
| Send request to the URL | |
| Run SQL add-in | Runs a specified SQL query upon execution |
There are other scheduled task add-ins, e.g. add-ins related to integration, but they will only be available if installed using the Apps area.
Tip
While DynamicWeb 9 relied on Windows Scheduled Tasks to be installed on the server, DynamicWeb 10 leverages .NET HostedService to manage scheduled tasks. The HostedService runs continuously in the background and is configured to execute a check every minute. During each check, it scans for any tasks that are scheduled to run at that time. This design ensures that tasks are executed according to their schedules.
If you need a way to programmatically run tasks, utilizing the Management API is an effective solution. By calling the TasksQuery, you can retrieve a list of available tasks that need to be executed. Then, use the TaskRunCommand to run these tasks as required. This process can be integrated into a Logic App, allowing for automated task execution within workflows. All you need is an API key from the DynamicWeb backend to authenticate your requests, ensuring secure and authorized access to the Management API.
Activity subtasks
An activity subtask is a scheduled run of an integration activity. When a schedule is added to an activity within the Activity Edit screen it is in fact automatically added in Scheduled tasks as a task with an Activity subtask.
Sequencing scheduled tasks
To ensure that data is imported/exported/cleaned/etc. correctly, it is crucial that mutually dependent tasks are executed in the correct order. When dealing with such related tasks, it can be a good idea to add them as Subtasks within the same Scheduled task.
When two or more subtasks are defined within a scheduled task, they are executed in a sequence defined by how they are sorted in the user interface (top to bottom). As an example, the image below shows a scheduled task "Business Central Item import" that contains two activity subtasks: "Import itemCategories" and "Import items". When the scheduled task is run, it triggers both subtasks in the order they are shown.

To change the sequence of subtasks, click Sort in the context menu of the Subtasks widget.

Triggering scheduled tasks remotely
Scheduled tasks can be triggered manually without accessing the DynamicWeb 10 user interface by running a cURL command with a DynamicWeb 10 API key and the TaskId of the scheduled tasks you wish to trigger.
Here is an example of a cURL. Insert your host URL, API key and Task ID and run this from a CLI to trigger a scheduled task remotely:
curl --request POST \
--url https://<YOUR_HOST>/Admin/Api/TaskRunCommand \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"TaskId": <YOUR_TASK_ID>
}'