Skip to content · Zum Inhalt

Insert Record Actions

Insert Record Actions (Action Type 10, Enum Value 10) automatically create new records in Business Central tables when business rules execute. This powerful capability enables automated record creation workflows, automatic generation of related documents or journal entries, creation of log or audit records, and duplication of records with modifications. Insert actions eliminate manual record creation for predictable scenarios, ensure that required related records are always created, and enable sophisticated automation of multi-step business processes. This section explains when Insert actions are appropriate, how to configure them correctly, and critical warnings about data volume and system performance that you must understand before implementing Insert actions.

14.1 When to Use Insert Actions

Insert actions are appropriate when business logic requires automatic creation of new records in response to specific events or conditions.

Appropriate Use Cases for Insert ActionsAutomatically Creating Related Records: When transactions should automatically generate related records in other tables, Insert actions eliminate manual creation steps. Examples include automatically creating journal entries when certain transactions occur, generating notification records for workflow systems, creating child records that depend on parent records, or populating audit trail tables with transaction snapshots.

Auto-Generating Required Documentation: When specific transaction types require supporting documentation or detail records, Insert actions ensure complete documentation without relying on users to remember to create them. Examples include creating default comment lines for certain document types, generating standard attachment records for specific transaction categories, or creating template-based detail records for master data.

Creating Log or Audit Records: When your organization requires comprehensive audit trails or custom logging beyond standard Business Central logging, Insert actions create log records automatically. Examples include logging high-value transactions, recording approval decisions, documenting exception handling, or creating compliance audit records.

Implementing Complex Workflow Automation: When business processes require multi-step record creation sequences, Insert actions automate the workflow. Examples include creating approval request records when transactions exceed thresholds, generating task records for follow-up actions, creating notification queue records for asynchronous processing, or auto-generating related orders or documents based on trigger events.

Duplicating Records with Modifications (Cloning): When users frequently need to create new records similar to existing records with specific variations, Insert actions automate the duplication process. Examples include creating backup copies of records before major modifications, generating alternate versions of documents for comparison, or replicating records across multiple scenarios with parameter variations.

When NOT to Use Insert ActionsHigh-Frequency Operations: If an Insert action would execute hundreds or thousands of times per day, carefully evaluate the data volume implications. Database growth and performance degradation can become significant problems. Consider whether batch processing, scheduled jobs, or alternative designs would better serve high-volume scenarios.

Records Requiring User Input: If the records being created require information that only users can provide (for example, explanatory notes, decisions, or context-specific data), Insert actions are not appropriate. Create records automatically only when all necessary field values can be determined programmatically.

Complex Record Creation Logic: If creating the records requires intricate multi-step logic, error handling, transaction management, or integration with external systems, consider using Custom Actions with AL code rather than attempting to configure overly complex Insert actions through business rules.

Tables with Strict Validation Requirements: Some Business Central tables have complex validation requirements, mandatory relationships, or intricate business logic in their OnInsert triggers. Attempting to insert records into these tables using Insert actions may fail or cause errors. Test thoroughly before enabling Insert actions for complex tables.

14.2 Configuring Insert Actions Step by Step

This section provides detailed instructions for creating and configuring Insert actions within your business rules.

Step 1: Create or Open the Business Rule

Navigate to the Business Rules page in Business Central

Open the Business Rule Set for the trigger table that should cause record insertion

Create a new Business Rule or open an existing rule that requires automatic record creation

Configure the Condition that determines when records should be created

The condition should evaluate to TRUE when the business logic requires new record creation. For example, if you want to create an approval request record when order amounts exceed $20,000, the condition would be [36:61] is >20000.

Step 2: Add a New Insert Action

In the Actions section of the Business Rule, create a new action line

Set the Action Type field to Insert Record (this is Action Type 10 in the enum)

The new action line is now configured to insert a record when the condition evaluates to TRUE

Step 3: Configure Insert Action Details

In the action line, locate the Action Code or Insert ID field

Enter a new code (for example, INSERT001) or select an existing insert configuration

Open the Insert Action Detail card by selecting the Action Code field

On the Insert Action Detail card, configure the insertion parameters:

Target Table: Specify the table where the new record will be created. Enter the table ID (for example, 50000 for a custom log table).

Field Assignments: For each field that should be populated in the new record, create an assignment line:

Field ID: The field to populate (for example, 1 for Entry No.)

Value: The value to assign. This can be:

Static literal value (for example, 'APPROVED')

Placeholder from trigger table (for example, [36:3] to copy order number)

Placeholder from linked table (for example, [18:2] to copy customer number)

Calculation (for example, \{[36:61] * 0.10\} to calculate 10% of order amount)

System placeholder (for example, [USERID] for current user, [TODAY] for current date)

Primary Key Handling: If the target table uses auto-incrementing primary keys (Entry No. pattern), you typically do not need to assign the primary key field—Business Central assigns it automatically. If the primary key requires explicit assignment, ensure your formula generates unique values.

Step 4: Test Extensively Before Enabling

Insert actions create permanent data. Testing is critical:

Test in sandbox environment only

Verify records are created in correct table

Verify all required fields are populated correctly

Verify primary key assignment works (records can be saved)

Test with various trigger scenarios

Verify no duplicate records are created unintentionally

Check that inserted records do not cause errors in dependent processes

Monitor database growth during testing

14.3 Critical Warnings About Data Volume and Performance

Database Growth Management

Insert actions create permanent database records. If not carefully controlled, this can cause:

Uncontrolled Database Growth: If Insert actions execute frequently and create records that are never deleted or archived, database size will grow continuously, eventually causing storage capacity problems and backup/restore delays.

Performance Degradation: As tables grow larger due to Insert actions, queries and reports that access those tables become slower. Indexes may become less efficient, and overall system performance can degrade.

RECOMMENDATION: Before implementing Insert actions, establish:

Data retention policies (how long records will be kept)

Archival procedures (moving old records to archive tables)

Cleanup jobs (scheduled tasks to delete obsolete records)

Monitoring (tracking table growth rates)

Frequency Analysis

Before enabling an Insert action in production, estimate execution frequency:

How many times per day will the condition evaluate to TRUE?

How many records will be created per day?

How many records will accumulate per month, per year?

Is this growth rate sustainable?

If the Insert action would create thousands of records per day, reconsider whether Insert actions are the appropriate solution or whether alternative designs (batch processing, summary records, scheduled jobs) would better manage data volume.

Performance Testing

Insert operations consume database resources. Test performance impact:

Measure transaction time before enabling Insert action

Measure transaction time after enabling Insert action

If Insert action adds noticeable delay, optimize or reconsider

14.4 Practical Examples

Example 1: Creating Audit Log Records for High-Value OrdersBusiness Requirement: Maintain an audit trail of all orders exceeding $50,000 for compliance reporting.

Configuration:

Trigger Table: 36 (Sales Header)

Trigger Type: Before Insert, Before Modify

Condition: [36:61] is >50000

Insert Action:

Target Table: 50000 (Custom Audit Log Table)

Field Assignments:

Field 1 (Entry No.): Auto-assigned by BC

Field 10 (Order No.): [36:3]

Field 20 (Customer No.): [36:2]

Field 30 (Amount): [36:61]

Field 40 (User ID): [USERID]

Field 50 (Timestamp): [CDT]

Field 60 (Event Type): 'HIGH_VALUE_ORDER'

Result: Every high-value order creates an audit log record with complete transaction context and user information.

Example 2: Auto-Creating Approval Request RecordsBusiness Requirement: When purchase orders exceed department budget authority, automatically create an approval request record for the department manager.

Configuration:

Trigger Table: 38 (Purchase Header)

Condition: [38:61] is >10000

Insert Action:

Target Table: 50001 (Custom Approval Request Table)

Field Assignments:

Field 10 (Request No.): [Unique ID formula]

Field 20 (Document Type): 'PURCHASE_ORDER'

Field 30 (Document No.): [38:3]

Field 40 (Amount): [38:61]

Field 50 (Requester): [USERID]

Field 60 (Request Date): [TODAY]

Field 70 (Status): 'PENDING'

Result: Approval requests are automatically created and ready for manager review without manual intervention.

Example 3: Creating Default Comment LinesBusiness Requirement: Certain customer orders automatically receive standard comment lines with shipping instructions.

Configuration:

Trigger Table: 36 (Sales Header)

Linked Table: 18 (Customer)

Condition: [18:50] is 'SPECIAL' (Customer Shipping Group = Special)

Insert Action:

Target Table: 44 (Sales Comment Line)

Field Assignments:

Field 1 (Document Type): [36:1]

Field 2 (No.): [36:3]

Field 4 (Line No.): [Next line number logic]

Field 10 (Comment): 'SPECIAL HANDLING: Contact logistics before shipping'

Result: Orders for special-handling customers automatically receive standardized comment lines.

14.5 Testing Insert Actions Thoroughly

Pre-Production Testing Checklist

Before enabling Insert actions in production, complete this testing checklist:

☐ Record Creation Verification

Confirm records are created in correct target table

Confirm primary key is assigned correctly (records save successfully)

Confirm all required fields are populated

Confirm no constraint violations occur

☐ Data Accuracy Verification

Confirm placeholder values substitute correctly

Confirm calculated values are accurate

Confirm system placeholders resolve correctly ([USERID], [TODAY], etc.)

Test with boundary values and edge cases

☐ Performance Verification

Measure transaction time impact

Test with realistic data volumes

Verify no timeout errors occur

Confirm acceptable user experience

☐ Integration Verification

Confirm inserted records do not cause errors in other processes

Verify dependent functionality works with auto-created records

Test interaction with other business rules

Confirm no duplicate records are created unintentionally

☐ Volume Management Verification

Estimate daily record creation count

Project monthly and annual table growth

Confirm data retention/archival plan exists

Verify monitoring is in place

Rollback Plan

Have a rollback plan ready:

Document how to disable the Insert action quickly

Document how to identify and delete erroneously created records

Have SQL scripts or processes ready for cleanup if needed

Know who to contact if problems occur