A modern, well-structured Business Central AL extension that provides product data retrieval services with comprehensive configuration and monitoring capabilities.
This extension has been completely refactored to follow Business Central AL best practices, focusing on:
- Performance: Efficient data retrieval with pagination and filtering
- Maintainability: Clean, well-documented code with proper separation of concerns
- Scalability: Configurable limits and optimized for large datasets
- Security: Proper permission management and input validation
- Echo Service: Basic connectivity testing endpoint
- Product Retrieval: Comprehensive product data API with filtering and pagination
- Configuration Management: Centralized setup for service parameters
- Telemetry: Optional logging for monitoring and diagnostics
- ✅ Batch Processing: Retrieves all matching products instead of just the first one
- ✅ Pagination: Configurable maximum records per request to prevent memory issues
- ✅ Efficient Filtering: Proper AL filtering instead of post-processing
- ✅ Optimized JSON Building: Streamlined JSON construction
- ✅ Proper Error Handling: TryFunction pattern with comprehensive error messages
- ✅ XML Documentation: Complete documentation for all procedures
- ✅ Consistent Naming: AL naming conventions throughout
- ✅ Separation of Concerns: Logical separation of functionality
- ✅ Configuration Table: Centralized settings management
- ✅ Setup Page: User-friendly configuration interface
- ✅ Validation Procedures: Built-in validation and testing capabilities
- ✅ Comprehensive Permissions: Granular permission sets
| Object Type | Object ID | Name | Purpose |
|---|---|---|---|
| Codeunit | 50000 | Echo Service | Main service functionality |
| Codeunit | 50001 | Echo Service Validation | Testing and validation procedures |
| Table | 50001 | Echo Service Setup | Configuration storage |
| Page | 50001 | Echo Service Setup | Configuration interface |
procedure Echo(): TextSimple connectivity test that returns a confirmation message.
procedure GetProducts(ItemFilter: Text; MaxRecords: Integer): TextRetrieves product data with optional filtering and pagination.
Parameters:
ItemFilter: Optional filter criteria (currently supports "Blocked = false")MaxRecords: Maximum records to return (0 = use setup default)
Returns: JSON formatted response with:
{
"success": true,
"message": "Products retrieved successfully",
"recordCount": 150,
"timestamp": "2025-09-05T10:30:00Z",
"products": [
{
"itemNo": "ITEM001",
"description": "Product Description",
"searchDescription": "Search Description",
"baseUnitOfMeasure": "PCS",
"unitPrice": 99.99,
"unitCost": 50.00,
"netWeight": 1.5,
"grossWeight": 2.0,
"unitVolume": 0.5,
"itemCategoryCode": "CATEGORY1",
"blocked": false,
"lastDateTimeModified": "2025-09-05T09:15:00Z",
"createdDateTime": "2025-01-01T00:00:00Z",
"inventory": 100.0
}
]
}procedure GetProductsByCategory(CategoryCode: Code[20]; MaxRecords: Integer): TextRetrieves products filtered by item category.
procedure GetActiveProducts(MaxRecords: Integer): TextRetrieves only non-blocked products.
Access the setup page through Echo Service Setup in the Administration area.
| Field | Description | Default | Range |
|---|---|---|---|
| Max Records Per Request | Maximum records returned per API call | 1000 | 1-10000 |
| Enable Telemetry | Enable/disable telemetry logging | True | Boolean |
| Default Item Filter | Default filter for item queries | Empty | Text[250] |
| API Timeout (Seconds) | Timeout for API operations | 30 | 5-300 |
- Execute permissions for Echo Service codeunit
- Read permissions for Setup table and Item table
- Basic operational permissions
- Full permissions for Setup table and page
- Administrative configuration access
- Execute permissions for testing functionality
All configuration data is classified as CustomerContent ensuring proper data handling compliance.
var
EchoService: Codeunit "Echo Service";
ProductData: Text;
begin
ProductData := EchoService.GetProducts('', 0); // Use setup defaults
end;var
EchoService: Codeunit "Echo Service";
ProductData: Text;
begin
ProductData := EchoService.GetActiveProducts(500); // Max 500 active products
end;var
EchoService: Codeunit "Echo Service";
Response: Text;
begin
Response := EchoService.Echo();
end;The extension includes validation procedures accessible through:
var
Validation: Codeunit "Echo Service Validation";
begin
Validation.RunAllValidations(); // Displays validation results
end;- ✅ Echo service connectivity
- ✅ JSON response format validation
- ✅ Setup table functionality
- ✅ Configuration parameter validation
- Efficient Filtering: Uses AL SetRange/SetFilter for database-level filtering
- Memory Management: Configurable pagination prevents excessive memory usage
- Lazy Loading: Inventory calculation only when needed
- Telemetry Optimization: Optional telemetry to reduce overhead
- Production: Max Records = 1000, Telemetry = True
- Development: Max Records = 100, Telemetry = True
- Testing: Max Records = 50, Telemetry = False
When telemetry is enabled, the service logs:
- Record counts for product retrievals
- Performance metrics
- Error conditions
- Usage patterns
Telemetry data is classified as SystemMetadata and uses the category "Echo Service" for filtering.
- Business Central version 22.0 or higher
- AL runtime 6.0 or higher
- Proper permissions for object installation
- Import the extension package
- Assign appropriate permission sets to users
- Configure setup parameters via the Setup page
- Test functionality using built-in validation
- ✅ Comprehensive XML documentation
- ✅ Consistent AL naming conventions
- ✅ Proper error handling with TryFunction
- ✅ Resource management and cleanup
- ✅ Granular permission management
- ✅ Data classification compliance
- ✅ Input validation and sanitization
- ✅ Secure configuration storage
- ✅ Database query optimization
- ✅ Memory-efficient processing
- ✅ Configurable resource limits
- ✅ Efficient JSON serialization
- ✅ Modular architecture
- ✅ Configuration-driven behavior
- ✅ Comprehensive logging
- ✅ Built-in testing capabilities
For issues or questions regarding this extension:
- Check the built-in validation results
- Review telemetry logs if enabled
- Verify permission assignments
- Consult the configuration parameters
- Complete refactoring of original Echo Service
- Added comprehensive product retrieval API
- Implemented configuration management
- Added security and permission framework
- Included validation and testing capabilities
- Performance optimizations and best practices implementation Service - Business Central Extension
The Echo Service is a small extension designed to test the connection establishment with Business Central for REST API calls. It provides a simple API endpoint that echoes back the input data, ensuring that the communication between the extension and Business Central works as expected.
- Simple API endpoint to test connection with Business Central for REST API calls.
- Echoes back the input data to confirm successful communication.
Before installing and using the Echo Service extension, ensure that the following prerequisites are met:
- Microsoft Dynamics 365 Business Central instance with REST API enabled.
- Necessary permissions to install extensions in Business Central.
- A developer or sandbox environment to deploy and test the extension.
To install the Echo Service extension in Business Central, follow these steps:
- Download the Echo Service .app file from the repository.
- In your Business Central environment, go to Extensions Management.
- Choose the Upload Extension option.
- Select the downloaded .app file and proceed with the installation.
OR
- Publish via VSCode Extension
Once the Echo Service extension is installed, you can test the connection with Business Central using the following steps:
- Obtain the endpoint URL for the Echo Service API.
- Perform a POST request to the endpoint with any desired data as the request payload.
- The Echo Service API will respond with the same data received in the request payload.
If you encounter any issues with the Echo Service extension or have trouble establishing a connection with Business Central, consider the following troubleshooting steps:
- Verify that the extension is installed correctly in Business Central.
- Check if the extension has the necessary permissions to access the REST API.
- Review the endpoint URL and ensure it is correct and accessible.
- Ensure that the input data is correctly formatted in the API request.
- Check Business Central logs for any error messages or issues during API calls.
If the issue persists, you may need to consult with your system administrator or Business Central support for further assistance.
We welcome contributions to enhance the functionality and usability of the Echo Service extension. If you find any bugs, have feature suggestions, or wish to contribute code improvements, please create a pull request in the repository.
The Echo Service Business Central Extension is open-source software licensed under the MIT License. Feel free to use, modify, and distribute it in accordance with the license terms.
For any questions or inquiries related to the Echo Service extension, please contact the project maintainers at project@example.com.