Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Echo Service - Business Central Extension

A modern, well-structured Business Central AL extension that provides product data retrieval services with comprehensive configuration and monitoring capabilities.

Overview

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

Features

Core Services

  • 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

Key Improvements Over Original Code

Performance Enhancements

  • 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

Code Quality Improvements

  • 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

Maintainability Features

  • Configuration Table: Centralized settings management
  • Setup Page: User-friendly configuration interface
  • Validation Procedures: Built-in validation and testing capabilities
  • Comprehensive Permissions: Granular permission sets

Architecture

Objects Overview

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

API Endpoints

1. Echo Service

procedure Echo(): Text

Simple connectivity test that returns a confirmation message.

2. Get Products (Enhanced)

procedure GetProducts(ItemFilter: Text; MaxRecords: Integer): Text

Retrieves 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
    }
  ]
}

3. Get Products by Category

procedure GetProductsByCategory(CategoryCode: Code[20]; MaxRecords: Integer): Text

Retrieves products filtered by item category.

4. Get Active Products

procedure GetActiveProducts(MaxRecords: Integer): Text

Retrieves only non-blocked products.

Configuration

Setup Parameters

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

Security

Permission Sets

ECHO_SERVICE

  • Execute permissions for Echo Service codeunit
  • Read permissions for Setup table and Item table
  • Basic operational permissions

ECHO_SETUP

  • Full permissions for Setup table and page
  • Administrative configuration access
  • Execute permissions for testing functionality

Data Classification

All configuration data is classified as CustomerContent ensuring proper data handling compliance.

Usage Examples

Basic Product Retrieval

var
    EchoService: Codeunit "Echo Service";
    ProductData: Text;
begin
    ProductData := EchoService.GetProducts('', 0); // Use setup defaults
end;

Filtered Product Retrieval

var
    EchoService: Codeunit "Echo Service";
    ProductData: Text;
begin
    ProductData := EchoService.GetActiveProducts(500); // Max 500 active products
end;

Testing Connectivity

var
    EchoService: Codeunit "Echo Service";
    Response: Text;
begin
    Response := EchoService.Echo();
end;

Validation and Testing

Built-in Validation

The extension includes validation procedures accessible through:

var
    Validation: Codeunit "Echo Service Validation";
begin
    Validation.RunAllValidations(); // Displays validation results
end;

Available Validations

  • ✅ Echo service connectivity
  • ✅ JSON response format validation
  • ✅ Setup table functionality
  • ✅ Configuration parameter validation

Performance Considerations

Optimizations Implemented

  1. Efficient Filtering: Uses AL SetRange/SetFilter for database-level filtering
  2. Memory Management: Configurable pagination prevents excessive memory usage
  3. Lazy Loading: Inventory calculation only when needed
  4. Telemetry Optimization: Optional telemetry to reduce overhead

Recommended Settings

  • Production: Max Records = 1000, Telemetry = True
  • Development: Max Records = 100, Telemetry = True
  • Testing: Max Records = 50, Telemetry = False

Monitoring and Telemetry

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.

Deployment

Prerequisites

  • Business Central version 22.0 or higher
  • AL runtime 6.0 or higher
  • Proper permissions for object installation

Installation Steps

  1. Import the extension package
  2. Assign appropriate permission sets to users
  3. Configure setup parameters via the Setup page
  4. Test functionality using built-in validation

Best Practices Implemented

Code Quality

  • ✅ Comprehensive XML documentation
  • ✅ Consistent AL naming conventions
  • ✅ Proper error handling with TryFunction
  • ✅ Resource management and cleanup

Security

  • ✅ Granular permission management
  • ✅ Data classification compliance
  • ✅ Input validation and sanitization
  • ✅ Secure configuration storage

Performance

  • ✅ Database query optimization
  • ✅ Memory-efficient processing
  • ✅ Configurable resource limits
  • ✅ Efficient JSON serialization

Maintainability

  • ✅ Modular architecture
  • ✅ Configuration-driven behavior
  • ✅ Comprehensive logging
  • ✅ Built-in testing capabilities

Support and Maintenance

For issues or questions regarding this extension:

  1. Check the built-in validation results
  2. Review telemetry logs if enabled
  3. Verify permission assignments
  4. Consult the configuration parameters

Version History

v1.0.0.0

  • 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

Overview

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.

Features

  • Simple API endpoint to test connection with Business Central for REST API calls.
  • Echoes back the input data to confirm successful communication.

Prerequisites

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.

Installation

To install the Echo Service extension in Business Central, follow these steps:

  1. Download the Echo Service .app file from the repository.
  2. In your Business Central environment, go to Extensions Management.
  3. Choose the Upload Extension option.
  4. Select the downloaded .app file and proceed with the installation.

OR

  1. Publish via VSCode Extension

Usage

Once the Echo Service extension is installed, you can test the connection with Business Central using the following steps:

  1. Obtain the endpoint URL for the Echo Service API.
  2. Perform a POST request to the endpoint with any desired data as the request payload.
  3. The Echo Service API will respond with the same data received in the request payload.

Troubleshooting

If you encounter any issues with the Echo Service extension or have trouble establishing a connection with Business Central, consider the following troubleshooting steps:

  1. Verify that the extension is installed correctly in Business Central.
  2. Check if the extension has the necessary permissions to access the REST API.
  3. Review the endpoint URL and ensure it is correct and accessible.
  4. Ensure that the input data is correctly formatted in the API request.
  5. 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.

Contributing

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.

License

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.

Contact

For any questions or inquiries related to the Echo Service extension, please contact the project maintainers at project@example.com.

About

Echo Service - Business Central Extension

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages