BCCL Documentation
Index

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

  1. Open the Service Task Card
  2. Change the Classification field from Normal to Automation
  3. 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:

  1. BCCL calls the Clone() function on the Automation task
  2. A new Clone task is created with all settings copied from the template
  3. The Clone gets an automatically incremented Task ID: {OriginalTaskID}-000000001, {OriginalTaskID}-000000002, etc.
  4. The Clone Parent field links back to the original Automation
  5. 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

  1. Automation task has ChangeLogFilterSinceLast enabled
  2. First Clone runs and processes all changes within the retention window
  3. The completion timestamp is recorded
  4. Next Clone starts its filter from that recorded timestamp
  5. 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

  1. Search for Job Queue Entries in Business Central (Alt-Q)
  2. Create a new entry
  3. 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
  1. Set the recurrence pattern:
    • Every N minutes for near real-time sync
    • Hourly for regular updates
    • Daily for end-of-day processing
  2. 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

  1. Job Queue fires at the scheduled interval
  2. The BCCL Run From Job Queue codeunit executes
  3. It finds Automation tasks that are due to run
  4. For each Automation, it calls Clone() to create a new instance
  5. The Clone is assigned to the agent and set to Ready
  6. The agent picks it up on its next poll (within 10 seconds)

Example: Automated Customer SQL Replication

Step 1: Create the Automation Task

  1. Create a new Service Task with ID CUST-SQL-SYNC
  2. Set Task to CHANGELOG
  3. Set Classification to Automation
  4. Set TableNo to 18 (Customer)
  5. Configure the mapping file
  6. Set Format to sql
  7. Set SqlConnect to your SQL Server connection string
  8. Set OutputFile to Customer (SQL table name)
  9. Enable ChangeLogFilterSinceLast
  10. 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

  1. Create a Job Queue Entry
  2. Set Object ID to BCCL Run From Job Queue
  3. Set recurrence to every 5 minutes
  4. 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

  1. Open the Automation task
  2. Navigate to the Clone List
  3. Review the status and logs of each Clone execution
  4. 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 ChangeLogFilterSinceLast with CHANGELOG tasks for efficient incremental sync. This setting exists for Service Tasks and Automations only; command-line runs express the window explicitly with a SystemModifiedAt view 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