Automations and Scheduling
Service Tasks can be converted into reusable Automations that run repeatedly, creating a new task instance (Clone) for each execution. Combined with the Business Central Job Queue, this enables fully automated, scheduled data operations.
Understanding Task Classifications
Service Tasks have three classifications:
| Classification | Purpose | Behavior |
|---|---|---|
| Normal | One-off tasks | Runs once, can be re-run by resetting status |
| Automation | Reusable templates | Creates a Clone for each execution |
| Clone | Execution instances | Created automatically from an Automation |
Converting a Task to an Automation
- Open the Service Task Card
- Change the Classification field from Normal to Automation
- The task now serves as a template for repeated execution
When an Automation task is run, it does not execute directly. Instead, it creates a Clone with a new Task ID and the Clone executes.
Task Cloning
How Cloning Works
When an Automation task is triggered:
- BCCL calls the
Clone()function on the Automation task - A new Clone task is created with all settings copied from the template
- The Clone gets an automatically incremented Task ID:
{OriginalTaskID}-000000001,{OriginalTaskID}-000000002, etc. - The Clone Parent field links back to the original Automation
- The Clone's status is set and it is picked up by the assigned agent
Example
If your Automation task ID is CUSTOMER-SYNC:
- First run creates:
CUSTOMER-SYNC-000000001 - Second run creates:
CUSTOMER-SYNC-000000002 - Third run creates:
CUSTOMER-SYNC-000000003
Viewing Clones
Use the Service Task Clone List page to view all Clone instances created from an Automation. This page shows:
- Clone Task ID
- Status (Completed, Failed, Working)
- Start and End times
- Execution results
Incremental Sync
Change Log Filter Since Last Run
The ChangeLogFilterSinceLast setting is a key feature for incremental data replication. When enabled on an Automation:
- Each Clone only processes changes that occurred since the last successful run
- BCCL tracks the timestamp of the last completed execution
- New Clones automatically filter Change Log entries from that timestamp forward
This is essential for efficient SQL replication, as it avoids reprocessing the entire Change Log on every run.
How It Works
- Automation task has
ChangeLogFilterSinceLastenabled - First Clone runs and processes all changes within the retention window
- The completion timestamp is recorded
- Next Clone starts its filter from that recorded timestamp
- Only new changes since the last run are processed
Configuration
On the Service Task Card:
- Set Task to
CHANGELOG - Set Classification to
Automation - Enable ChangeLogFilterSinceLast
- Configure table, mapping, SQL connection, and output table
- Assign an agent
Scheduling with the Business Central Job Queue
The Business Central Job Queue allows you to schedule Automation tasks to run at regular intervals.
Setting Up a Job Queue Entry
- Search for Job Queue Entries in Business Central (Alt-Q)
- Create a new entry
- Configure:
| Field | Value |
|---|---|
| Object Type to Run | Codeunit |
| Object ID to Run | BCCL Run From Job Queue (80807) |
| Description | Descriptive name (e.g., "Customer SQL Sync") |
| Recurrence | Set your desired interval |
- Set the recurrence pattern:
- Every N minutes for near real-time sync
- Hourly for regular updates
- Daily for end-of-day processing
- Set the Job Queue Entry to Ready to start scheduling
Recurrence Examples
| Scenario | Recurrence Setting |
|---|---|
| Near real-time replication | Every 1 minute |
| Regular sync | Every 15 minutes |
| Hourly updates | Every 60 minutes |
| Daily batch | Once per day at a specific time |
How the Job Queue Triggers Automation
- Job Queue fires at the scheduled interval
- The BCCL Run From Job Queue codeunit executes
- It finds Automation tasks that are due to run
- For each Automation, it calls
Clone()to create a new instance - The Clone is assigned to the agent and set to Ready
- The agent picks it up on its next poll (within 10 seconds)
Example: Automated Customer SQL Replication
Step 1: Create the Automation Task
- Create a new Service Task with ID
CUST-SQL-SYNC - Set Task to
CHANGELOG - Set Classification to
Automation - Set TableNo to
18(Customer) - Configure the mapping file
- Set Format to
sql - Set SqlConnect to your SQL Server connection string
- Set OutputFile to
Customer(SQL table name) - Enable ChangeLogFilterSinceLast
- Assign your agent
Step 2: Run the Initial Full Load
Before starting incremental sync, perform an initial full load:
BCCL -t getdata -s table=18 -f sql -o Customer --sqlconnect "Server=localhost;Database=BCData;Trusted_Connection=yes" --sqlprecommand "TRUNCATE TABLE Customer"
Step 3: Schedule the Job Queue
- Create a Job Queue Entry
- Set Object ID to BCCL Run From Job Queue
- Set recurrence to every 5 minutes
- Set status to Ready
Result
Every 5 minutes, a new Clone is created that processes only the Customer changes since the last successful run, keeping your SQL Server table in near real-time sync with Business Central.
Managing Automations
Pausing an Automation
To temporarily stop an Automation from running:
- Set the Job Queue Entry status to On Hold
- Or change the Automation task's Classification back to Normal
Viewing Execution History
- Open the Automation task
- Navigate to the Clone List
- Review the status and logs of each Clone execution
- Failed Clones retain their error information for troubleshooting
Cleaning Up Old Clones
Over time, Clone tasks accumulate. Periodically review and delete old completed Clones to keep the task list manageable.
Tips and Best Practices
- For ongoing SQL replication, the recommended approach is the command-line route: the scripts and mapping files generated by the SQL Bundle Builder, scheduled with Windows Task Scheduler. Service Task Automations with the Job Queue remain available and are useful when you specifically want everything managed inside Business Central, but keep in mind that one task = one table and one agent executes only one task at a time, so high table counts or short intervals require multiple agents. See Service Tasks vs. Scripted Runs.
- Always perform an initial full load before starting incremental replication
- Use
ChangeLogFilterSinceLastwith CHANGELOG tasks for efficient incremental sync. This setting exists for Service Tasks and Automations only; command-line runs express the window explicitly with aSystemModifiedAtview filter instead (see Filtering Data) - Start with longer intervals and reduce once you confirm stability
- Monitor Clone failures regularly via the Clone List
- Use short Automation Task IDs (10 characters or fewer) that indicate their purpose, so that the 10-character clone suffix fits within the 20-character Task ID limit
- Ensure the Business Central Change Log is enabled for deletions on all replicated tables; inserts and updates do not require the Change Log
- Keep retention periods reasonable to limit processing windows
- Assign dedicated agents for high-frequency automations