Erik's ToolBox Documentation
Index

Batch Processing Overview

Introduction

Batch processing in Erik's ToolBox for Business Central is a wizard-driven tool that allows you to perform bulk data modifications across your Business Central environment. Rather than manually editing records one at a time or writing custom AL code, you can use the guided wizard to search for records, define changes, and execute updates in a controlled and auditable manner.

Whether you need to update a single field across thousands of records, clean up legacy data after a migration, or apply standardized values to a subset of entries, the batch processing feature provides a structured workflow to accomplish these tasks safely and efficiently.

What Is Batch Processing?

Batch processing is a multi-step wizard that walks you through the entire process of selecting, filtering, and modifying records in any table within Business Central. The wizard is accessed through the Batch Processing page and is managed by the Batch Processing Management codeunit.

At its core, batch processing lets you:

  • Select a target table in your Business Central database.
  • Apply filters to narrow down the exact records you want to modify.
  • Choose the field or fields you want to update.
  • Define the new values or replacement rules for those fields.
  • Preview the changes before committing them.
  • Execute the modifications with full history tracking.

The entire process is designed to minimize risk while maximizing efficiency. Every step includes confirmation points, and all changes are recorded in the history tables for audit and compliance purposes.

Common Use Cases

Batch processing is well suited for a wide range of scenarios that would otherwise require tedious manual work or custom development. The following are some of the most common use cases:

Mass Field Updates

When you need to change the value of a particular field across a large number of records, batch processing is the most efficient approach. For example, you might need to update a default posting group, change a dimension value, or set a status field for all records that meet certain criteria.

Data Cleanup

After data migrations, imports, or system upgrades, you may find inconsistencies or incorrect values scattered across your tables. Batch processing allows you to identify and correct these issues in bulk rather than fixing them record by record.

Standardization

When business rules change or when you need to enforce consistent formatting, batch processing lets you apply standardized values across your data. This could include normalizing text fields, updating code values, or aligning records with new classification schemes.

Periodic Maintenance

Some organizations perform regular data maintenance tasks, such as archiving, reclassifying, or updating status fields at the end of a fiscal period. Batch processing provides a repeatable and auditable way to handle these recurring tasks.

How Batch Processing Differs from Custom Code

If you are familiar with AL development in Business Central, you might wonder why you would use batch processing instead of writing a custom codeunit or report. The key differences are:

Aspect Batch Processing Wizard Custom AL Code
Skill required No coding knowledge needed for simple changes Requires AL development expertise
Setup time Minutes to configure through the wizard Hours or days for development, testing, and deployment
Flexibility Guided steps for standard field modifications Unlimited flexibility for complex logic
Audit trail Built-in history tracking and record logging Must be implemented manually
Deployment No deployment needed; runs directly in the client Requires publishing an extension or modifying existing code
Repeatability Process configurations can be referenced from history Code can be reused but requires a developer to run it

For straightforward field updates and data corrections, the wizard approach saves significant time and removes the dependency on developer resources. However, for complex transformations that involve conditional logic, calculations across multiple tables, or integration with external systems, you may need the full power of AL code.

Advanced Processing with AL Code

Batch processing is not limited to simple field value replacements. For more complex scenarios, you can pass AL code directly into the processing engine using the SetLibrarySource() function. This hybrid approach gives you the convenience of the wizard's filtering and execution framework combined with the flexibility of custom code.

When you use SetLibrarySource(), you provide AL code that defines the transformation logic. The batch processing engine then applies that logic to each record that matches your filters. This is particularly useful when:

  • The new value depends on a calculation or lookup from another table.
  • You need to apply conditional logic that varies based on record attributes.
  • The transformation involves multiple fields that must be updated together.
  • You need to perform validations before applying changes.

The RunTheProcess() function executes the batch process after all configuration is complete, whether you are using the standard wizard flow or custom AL code provided through SetLibrarySource().

For more details on using AL code with batch processing, see Batch Processing Usage.

The Seven-Step Wizard

The batch processing wizard consists of seven steps, numbered 0 through 6. Each step builds on the previous one, guiding you through the complete process from initial setup to final execution. Here is a brief overview of each step:

Step 0: Welcome

The starting point of the wizard. You confirm the company context you are working in and prepare to begin the batch processing workflow. This step ensures you are operating in the correct environment before making any changes.

Step 1: Select Table

You choose the table that contains the records you want to modify. The wizard presents the available tables in your Business Central environment, and you select the one that is relevant to your task.

Step 2: Apply Filters

You define filters to narrow down the set of records that will be affected by the batch process. This step is critical for ensuring that only the intended records are modified. You can preview the record count to verify that your filters are producing the expected results.

Step 3: Select Fields

You choose which field or fields within the selected table you want to modify. The wizard displays the available fields for the table you selected in Step 1.

Step 4: Set Values

You define the new values or replacement rules for the fields you selected. This is where you specify what the updated data should look like after the batch process runs.

Step 5: Preview

Before any changes are committed, you review a summary of the planned modifications. This step shows you the affected records and the changes that will be applied, giving you a final opportunity to verify everything is correct.

Step 6: Execute

You confirm and run the batch process. The system applies the defined changes to all matching records and logs the results in the history tables. You can monitor the progress as the process runs.

For a detailed walkthrough of each step, see Batch Processing Usage.

Key Components

The batch processing feature relies on several core objects within Erik's ToolBox:

  • Batch Processing: The main wizard page that hosts the batch processing workflow.
  • Batch Processing Management: The management codeunit that orchestrates the batch processing logic, including filtering, field selection, and execution.
  • Batch Processing: The table that stores process configuration data, defining what each batch process is set up to do.
  • Batch Processing Filters: The table that stores the filter criteria applied during Step 2 of the wizard.
  • Batch Processing History: The table that records the history of all batch processes that have been executed, including timestamps, affected tables, and user information.

Safety Features

Batch processing includes several safety mechanisms to protect your data:

  • Confirmation steps: The wizard requires you to explicitly confirm your choices at multiple points before any changes are applied.
  • Preview before execution: Step 5 gives you a complete overview of what will change, allowing you to catch mistakes before they happen.
  • History tracking: Every batch process is recorded in the Batch Processing History table, including details about what was changed, when, and by whom.
  • Audit trail: Individual record modifications are logged in the Records Modified page, providing a granular view of before-and-after values for each affected record.
  • Company context verification: Step 0 confirms the company you are working in, reducing the risk of accidentally modifying data in the wrong company.

These features work together to ensure that batch processing is a controlled and reversible operation whenever possible.

Permission Requirements

To use the batch processing feature, you must have the SUPER role assigned to your user account in Business Central. This requirement exists because batch processing can modify data across any table in the system, and unrestricted access is necessary to ensure the wizard can read from and write to all relevant tables.

If you do not have the SUPER role, you will not be able to access the Batch Processing page or execute batch processes. Contact your system administrator if you need access to this feature.

Next Steps

Now that you understand what batch processing is and how it fits into your workflow, you can proceed to the detailed usage guide for step-by-step instructions on running your first batch process.