Skip to content

Conversation

dayland
Copy link

@dayland dayland commented Oct 9, 2025

This pull request introduces enhanced error handling and telemetry logging to the historical data loading process in the E-Doc. Historical Matching codeunit. The main improvements are focused on making the data load process more robust and observable, especially in error scenarios and performance tracking.

Error handling and telemetry improvements:

  • Added a new [TryFunction] procedure TryLoadHistoricalData to wrap the historical data loading, enabling graceful handling of load failures.
  • On failure to load historical data, the code now logs a detailed error event using FeatureTelemetry.LogError, including the e-document system ID and error message for better diagnostics.

Performance and usage tracking:

  • Enhanced the LoadHistoricalDataIntoTempTable procedure to measure and log the time taken, number of records loaded, and whether the record limit was reached, using FeatureTelemetry.LogUsage and a telemetry dimensions dictionary.

Supporting changes:

  • Added new label constants for error messages and event tokens (HistoricalDataLoadFailedErr, AIHistoricalDataLoadEventTok) to improve error reporting and event tracking.
  • Declared additional variables for telemetry, error handling, and data tracking (FeatureTelemetry, EDocSystemId, ErrorMessage, TelemetryDimensions) to support the new functionality.

Fixes AB#604259

@dayland dayland requested a review from a team as a code owner October 9, 2025 14:11
@dayland dayland changed the title Enhance historical data loading with error handling and telemetry [Payables Agent] Enhance historical data loading with error handling and telemetry Oct 9, 2025
@github-actions github-actions bot added this to the Version 28.0 milestone Oct 9, 2025
// Load historical data
LoadHistoricalDataIntoTempTable(TempPurchInvLine, VendorNo, EDocHistoricalMatchingSetup);
// Load historical data with error handling
if not TryLoadHistoricalData(TempPurchInvLine, VendorNo, EDocHistoricalMatchingSetup) then begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thinking a bit on all the AI tools we have, maybe we could move this to reused across all tools for consistent telemetry? Wdyt

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment this is the only place we load large amounts of historical data, and I think this pattern will go away when we move to a model-first approach. So, I don't think refactoring this now to make generic is needed IMO.

Groenbech96
Groenbech96 previously approved these changes Oct 10, 2025
@dayland dayland requested a review from Groenbech96 October 10, 2025 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants