Use Cases
This page provides practical examples of using business logic APIs for common integration scenarios.
Document Processing
Posting Documents
Scenario: External system needs to post a sales order
Method: Sales-Post.Run
Workflow:
- Create sales order via table API
- Call posting method via business logic API
- Handle response
Benefits:
- Full BC posting logic executes
- Entries created correctly
- Validation applied
Posting Prepayment Invoices
Scenario: Automate posting of sales prepayment invoices from a Power Automate flow
Method: codeunit 442 (Sales-Post Prepayment), exposed as a business logic API and called from the flow
This is distinct from standard document posting through Sales-Post (codeunit 80). Purchase prepayment posting is planned for an upcoming release.
Posting an Item Journal Line
Scenario: post item journal lines from Power Automate
Method: the Item Jnl.-Post Line codeunit — which requires its OnRun parameter table
Workflow:
- Insert a record into the
ItemJnlPostLineOnRuntable, carrying the Item Journal Line to post - Run the codeunit through its bound action
Running the codeunit without inserting the parameter record first fails. See Expose Codeunits.
Releasing Documents
Scenario: Approve documents from external workflow
Method: Release Sales Document.Run
Workflow:
- External approval system approves
- Call release method
- Document status updates in BC
Note that the calling identity needs the permission set from your published app — a release touches many tables, and Azure AD API permissions alone are not enough.
Printing/Emailing
Scenario: Trigger document send from external system
Method: Document sending methods
Use for:
- Customer-triggered document requests
- Automated email workflows
- Integration with document management
Validation and Checking
Credit Check
Scenario: Check customer credit before accepting order
Method: Credit limit checking methods
Workflow:
- External system receives order
- Call credit check method
- Proceed or reject based on response
Inventory Availability
Scenario: Check stock before promising delivery
Method: Item availability methods
Use for:
- E-commerce inventory display
- Order promising systems
- Supply chain integration
Price Calculation
Scenario: Get BC pricing for external quote
Method: Price calculation methods
Workflow:
- Pass item and customer
- BC calculates price with discounts
- Return price to external system
Process Automation
Approval Workflows for SOD Documents
The constraint: Power Automate cannot be triggered by an event raised from a SOD Document feature. Its Business Central event interface covers only a small set of Microsoft-defined events, and custom events are not exposed to it. There is no way to kick off an approval directly from a button on a SOD document page.
The supported pattern is polling:
- Add a status option field to the document — Open, Awaiting Approval, Approved
- Build a Power Automate flow on a recurring schedule (every X minutes) that reads the document status through the Table API
- When the flow finds records with status Awaiting Approval, it starts the approval process
- On completion it PATCHes the status back to Approved or Open, depending on the outcome
The trade-off, stated plainly: approvals are not immediate — there is a delay until the next scheduled run. In practice this works for most scenarios.
Document-level fields such as the status option are exposed for read and update through the document feature's Table API.
Period Close
Scenario: Automate month-end processes
Methods: Various closing routines
Workflow:
- Scheduled job triggers at month end
- Call BC closing methods
- Verify completion
Data Synchronization
Scenario: Sync data with external system
Methods: Various sync/export methods
Workflow:
- External system requests sync
- Call BC method to prepare data
- Transfer data
Batch Processing
Scenario: Run BC batch jobs externally
Methods: Batch processing codeunits
Use for:
- Scheduled calculations
- Mass updates
- Periodic maintenance
Power Platform Integration
Power Automate Workflows
Approval Workflow
- Trigger: Purchase order exceeds limit
- Action: Send approval to manager
- Action (approved): Call Release method
- Action (rejected): Call cancel method
Error Notification
- Trigger: Scheduled check
- Action: Call BC validation method
- Condition: If errors returned
- Action: Send notification email
Power Apps Integration
Order Entry App
- User creates order in Power App
- App calls table API to create order
- User clicks "Submit"
- App calls release method
- Confirmation displayed
Inventory Check App
- User scans item barcode
- App calls inventory check method
- Display stock levels
- Allow quantity adjustment
External System Integration
E-commerce Integration
Scenario: Online store integrated with BC
Methods used:
- Inventory check before cart
- Price calculation for display
- Order posting on checkout
- Customer creation for new customers
EDI Integration
Scenario: Trading partner sends EDI orders
Workflow:
- EDI system receives order
- Creates BC sales order via API
- Calls validation method
- Calls release/post method
- Returns confirmation
CRM Integration
Scenario: CRM creates opportunities that become quotes
Methods used:
- Customer lookup/creation
- Quote creation
- Quote to order conversion
- Status updates
Security Patterns
Service Account
Use dedicated service accounts:
- Specific permissions
- Audit logging
- Credential management
Role-Based Access
Control method access:
- Sales methods for sales integration
- Inventory methods for warehouse integration
- Financial methods restricted
Input Validation
Always validate:
- Parameter values
- Business rules
- Security context
Error Handling Patterns
Graceful Degradation
1. Call method
2. If success → continue
3. If error → log, notify, retry or fallback
Transaction Management
For multi-step processes:
1. Start transaction (if possible)
2. Step 1
3. Step 2
4. If all success → commit
5. If any fail → rollback
Logging and Monitoring
Track all API calls:
- Request parameters
- Response status
- Execution time
- Error details
Best Practices
Design Principles
- Keep methods focused
- Validate inputs early
- Return meaningful responses
- Handle errors gracefully
Performance
- Minimize round trips
- Batch where possible
- Consider timeout settings
- Plan for scale
Maintenance
- Document all exposed methods
- Version your integrations
- Plan for BC upgrades
- Test after updates