How to Set Up Post-Processing
This guide explains how to configure post-processing to automatically run custom business logic after records are created during an import.
What is Post-Processing?
Post-processing allows you to automatically run custom business logic after the Integration Framework creates records in Business Central. This is useful for scenarios where importing creates records that require immediate follow-up action.
Examples:
- Release Documents - Automatically release sales orders or purchase orders after import
- Cascade Updates - Update related records based on newly created data
- Trigger Workflows - Start business workflows or approvals
- Calculate Extensions - Run extension-specific calculations or validations
- Send Notifications - Generate alerts or emails based on created records
How Post-Processing Works
Basic Workflow
1. Import Runs
└─ Parse source file
└─ Create records in BC
2. Post-Processing Executes (based on trigger mode)
└─ Run custom post-processing codeunit
└─ Access created records via their SystemId
└─ Execute your business logic
3. Results Tracked
└─ Post-process entries recorded
└─ Status: Ready, Completed, or Error
└─ Failed entries can be manually retried
Post-Processing Trigger Modes
Post-processing can execute at different times depending on your needs:
| Trigger Mode | When it Runs | Use Case |
|---|---|---|
| Per Document | Immediately after each document is created (during import) | Release orders one at a time as they're created; need results before next document |
| After Processing | Once after all rows are imported (end of import) | Wait for full batch to complete before post-processing; fewer background jobs |
| Job Queue | Asynchronously in background (after import completes) | Long-running logic; don't block user during post-processing |
Trigger Mode Details
Per Document (Immediate)
- Executes immediately after each header/master record is created
- Blocking mode - user waits for this post-processing
- Most frequent execution (once per document)
- Example: Release each sales order as it's created
After Processing (Immediate)
- Executes once when all rows have been imported
- Blocking mode - user waits
- Execute once per import
- Example: Auto-release all orders in one batch
Job Queue (Deferred)
- Executes asynchronously in background after import completes
- Non-blocking - user continues working
- Can take longer (no user session timeout)
- Status monitored via Integration Records page
- Example: Run complex business logic without blocking user
Setting Up Post-Processing
Step 1: Create Your Post-Processing Codeunit
Create an AL codeunit that implements the post-processing logic:
codeunit 50100 "My Post Processing"
{
procedure RunPostProcessing(var NAVXIFPostProcessEntry: Record "NAVX IF Post Process Entry")
begin
// Your custom logic that processes the created records
if NAVXIFPostProcessEntry.FindSet() then
repeat
ProcessRecord(NAVXIFPostProcessEntry);
until NAVXIFPostProcessEntry.Next() = 0;
end;
local procedure ProcessRecord(NAVXIFPostProcessEntry: Record "NAVX IF Post Process Entry")
var
SalesHeader: Record "Sales Header";
begin
// Reload the created record using SystemId
if SalesHeader.GetBySystemId(NAVXIFPostProcessEntry."System Id") then begin
// Perform your business logic
// Example: Release the sales order
SalesHeader.Validate(Status, SalesHeader.Status::Released);
SalesHeader.Modify();
end;
end;
}
Step 2: Configure Integration for Post-Processing
- Open your Integration record
- Set: Post-Processing Codeunit - Select the codeunit you created
- Set: Post-Processing Trigger - Choose when to execute:
- Per Document (Immediate) - After each document
- After Processing (Immediate) - After all rows imported
- Job Queue (Deferred) - Background execution
- Save
Note: Post-processing only runs if a Post-Processing Codeunit is configured.
Step 3: Run Import
- Run your integration import as normal
- Records are created in BC
- Post-processing executes based on your trigger mode
- Post-process entries are tracked and can be reviewed
Sample Post-Processing: Release Sales Orders
Here's a complete example of releasing imported sales orders automatically:
Codeunit: Release Sales Orders After Import
codeunit 50101 "Release Sales Orders IF"
{
/// <summary>
/// Post-processing codeunit that releases sales orders after they are created by import.
/// Called by the Integration Framework after records are inserted.
/// </summary>
procedure RunPostProcessing(var NAVXIFPostProcessEntry: Record "NAVX IF Post Process Entry")
var
SalesHeader: Record "Sales Header";
ReleaseSalesDoc: Codeunit "Release Sales Document";
ErrorMessage: Text;
begin
if NAVXIFPostProcessEntry.FindSet() then
repeat
if SalesHeader.GetBySystemId(NAVXIFPostProcessEntry."System Id") then begin
try
// Release the document
ReleaseSalesDoc.Run(SalesHeader);
// Mark post-process entry as completed
NAVXIFPostProcessEntry.Status := "Process Status"::Completed;
catch ErrorMessage begin
// If release fails, mark as error
NAVXIFPostProcessEntry.MarkAsError(ErrorMessage);
end;
end;
until NAVXIFPostProcessEntry.Next() = 0;
end;
}
Configuration Steps
- Create codeunit and assign object number (e.g., 50101)
- Publish and deploy to Business Central
- Open your Sales Order Import Integration record
- Set: Post-Processing Codeunit = 50101 (Release Sales Orders IF)
- Set: Post-Processing Trigger = "Per Document" (to release as they're created)
- Save
Result
When you import sales orders:
- Each order is created from the source file
- Post-processing immediately runs for that order
- The order is automatically released
- Next order is created and releases
- All orders released by the end of import
Monitoring Post-Processing
View Post-Process Entries
After running an import with post-processing:
- Open NAV-X Integration Records page
- Filter by your Integration
- Look at the record statuses:
- Ready - Awaiting post-processing
- Completed - Post-processing successful
- Error - Post-processing failed (see error message)
Check Post-Processing Results
- Choose Tell me → Search for Post-Process Entries
- View all post-processing results
- Filter by Integration and date range
- See status, error messages, and timestamps
Retry Failed Post-Processing
If post-processing fails:
- Fix the underlying issue (e.g., if release failed, resolve workflow blocks)
- Select failed post-process entry
- Choose Retry action
- Post-processing runs again
Post-Processing with Different Trigger Modes
Example: Per Document Mode (Recommended for Most Cases)
Configuration:
- Post-Processing Trigger = "Per Document (Immediate)"
Timeline:
10:00:00 - Order SO001 created
10:00:01 - Released immediately after SO001 created
10:00:02 - Order SO002 created
10:00:03 - Released immediately after SO002 created
10:00:05 - All orders created and released
Pros: Validate each order released while you watch; catch issues quickly Cons: Slower (synchronous); user waits for each release cycle
Example: After Processing Mode (Batch Scenario)
Configuration:
- Post-Processing Trigger = "After Processing (Immediate)"
Timeline:
10:00:00 - Order SO001 created
10:00:00 - Order SO002 created
10:00:00 - Order SO003 created
10:00:01 - All three orders created
10:00:02 - Release all three orders together
10:00:03 - Import and post-processing complete
Pros: Efficient for batches; all post-processing in one cycle Cons: If one order fails to release, all fail to process
Example: Job Queue Mode (Large Imports)
Configuration:
- Post-Processing Trigger = "Job Queue (Deferred)"
Timeline:
10:00:00 - Order SO001 created
10:00:00 - Order SO002 created
10:00:00 - Order SO3000 created
10:00:01 - All 3000 orders created
10:00:02 - Post-processing queued to background job
10:00:03 - User notified "Import complete; post-processing in progress"
10:00:03+ - User can continue working
10:15:00 - Background processing completes orders
10:15:00 - User notified "Post-processing complete; 3000 orders released"
Pros: Non-blocking; user can work; good for large batches Cons: Asynchronous; may take longer; separate monitoring needed
Best Practices for Post-Processing
- Keep Post-Processing Fast - Avoid long-running operations in per-document mode
- Use Job Queue for Heavy Logic - Set trigger to Job Queue if post-processing is slow
- Handle Errors Gracefully - Catch exceptions and update NAVXIFPostProcessEntry status
- Test Thoroughly - Test post-processing with sample data before production
- Document Your Logic - Add comments explaining what post-processing does
- Monitor Results - Check Post-Process Entries page after imports
- Set Appropriate Trigger Mode - Match trigger mode to your use case (per document, after all, or deferred)
- Consider System Performance - Per-document mode on large imports could be slow
Common Post-Processing Tasks
Release Documents
// Release sales order
ReleaseSalesDoc.Run(SalesHeader);
// Release purchase order
ReleasePurchDoc.Run(PurchaseHeader);
Update Related Records
// Update customer after order import
Customer.Get(SalesHeader."Bill-to Customer No.");
Customer."Last Sales Order Date" := Today();
Customer.Modify();
Send Notifications
// Send notification after orders created
CreateNotification("Orders import complete and released");
MyNotification.Send();
Calculate Totals
// Recalculate invoice totals
SalesInvHeader."Amount Including VAT" := CalculateTotal(SalesInvHeader);
SalesInvHeader.Modify();
Troubleshooting Post-Processing
Post-Processing Not Running
Check:
- Is Post-Processing Codeunit configured on Integration?
- Is the codeunit number valid and published?
- Does the code have a public procedure named
RunPostProcessing? - Are post-process entries being created (check Post-Process Entries page)?
Post-Processing Has Errors
Check:
- View error message in Post-Process Entries
- Verify the business logic (e.g., can the order actually be released based on BC rules?)
- Check if record exists (use GetBySystemId)
- Ensure all required fields are filled
Performance Issues
If post-processing is slow:
- Profile the codeunit to find bottlenecks
- Move to Job Queue trigger mode (async)
- Optimize queries (avoid nested loops)
- Consider batching logic (use After Processing trigger instead of Per Document)