Repository navigation
Add SpencerMetrics Counter Management Features - #2
Conversation
PropmanProphecy
commented
Nov 10, 2026
- Created "PVS SM Count FactBox" page to display count summaries.
- Introduced "PVS SM Count Summary Buffer" temporary table for storing count data.
- Developed "PVS SM Counter Entries" page for viewing counter entries.
- Implemented "PVS SM Counter Entry" table to manage individual counter entries.
- Added "PVS SM Counts Sum By UOM" query to aggregate counts by UOM.
- Created "PVS SM Assign To Job Costing" page for assigning counts to job costing entries.
- Developed "PVS SM Counter Worker" codeunit for processing counter data.
- Implemented "PVS SM Session Manager" codeunit for managing session states.
- Added "PVS SM Api Client" codeunit for handling API interactions with SpencerMetrics.
- Created timer control add-in for periodic updates in the UI.
- Extended "PVS SF Electronic Ticket" page to include count summary.
- Extended "PVS Job Sheet" table to include SpencerMetrics key.
- Created "PVS SM Count FactBox" page to display count summaries. - Introduced "PVS SM Count Summary Buffer" temporary table for storing count data. - Developed "PVS SM Counter Entries" page for viewing counter entries. - Implemented "PVS SM Counter Entry" table to manage individual counter entries. - Added "PVS SM Counts Sum By UOM" query to aggregate counts by UOM. - Created "PVS SM Assign To Job Costing" page for assigning counts to job costing entries. - Developed "PVS SM Counter Worker" codeunit for processing counter data. - Implemented "PVS SM Session Manager" codeunit for managing session states. - Added "PVS SM Api Client" codeunit for handling API interactions with SpencerMetrics. - Created timer control add-in for periodic updates in the UI. - Extended "PVS SF Electronic Ticket" page to include count summary. - Extended "PVS Job Sheet" table to include SpencerMetrics key.
|
Issue link validation failed - this is NOT a merge conflict. Could not find linked issues in the pull request description. Please make sure the pull request description contains a line that contains 'Fixes #' followed by the issue number being fixed (e.g. |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved compilation errors and critical allocation, parsing, and job-boundary defects can block the build, cause duplicate-key failures, and corrupt or lose production counts.
13 open issues
Capture synchronized counter readings at job start and stop · New Resolve resumed jobs from the latest start marker · New Avoid race conditions when allocating session log entry numbers · New Validate Time costing type before updating quantity · New Do not persist samples when counter parsing fails · New Resolve active context from explicit boundary markers · New Add terminating semicolons to both control add-in procedures · New Grant page execute permissions in the full permission set · New Initialize the setup singleton during per-company installation · New Clear and refresh the FactBox when context resolution fails · New Recover collection when worker startup or execution fails · New Backfill API identity keys for existing job sheets · New Pass explicit action names to SendGetRequest · New
What changed in this PR
Adds a SpencerMetrics integration that collects machine counts and connects them to PrintVis shop-floor operations and job costing.
Changes:
- Adds API polling, background session management, configuration, and session logging.
- Introduces counter storage, live count summaries, and manual job-costing assignment.
- Exposes order-sheet data through an API and adds installation, permissions, and project configuration.
Paths are relative to Apps/SpencerMetrics/PrintVis SpencerMetrics/.
| File | Description |
|---|---|
src/Utilities/TimerAddIn/timer.js |
Implements periodic UI refresh callbacks. |
src/Utilities/TimerAddIn/PVSSMTimerAddIn.ControlAddin.al |
Declares the timer control interface. |
src/Services/PVSSMApiClient.Codeunit.al |
Authenticates, retrieves counters, and calculates deltas. |
src/PrintVisIntegration/PVSSMSheet.TableExt.al |
Generates SpencerMetrics job-sheet keys. |
src/PrintVisIntegration/PVSSMElectronicTicket.PageExt.al |
Adds the count summary to electronic tickets. |
src/CounterManagement/PVSSMSessionManager.Codeunit.al |
Starts, stops, rotates, and logs collection sessions. |
src/CounterManagement/PVSSMCounterWorker.Codeunit.al |
Runs background counter polling. |
src/CounterManagement/PVSSMAssignToJobCosting.Page.al |
Provides manual count assignment. |
src/CounterManagement/Entries/PVSSMCountSummaryBuffer.Table.al |
Stores temporary summary rows. |
src/CounterManagement/Entries/PVSSMCountsSumByUOM.Query.al |
Aggregates counts by unit of measure. |
src/CounterManagement/Entries/PVSSMCountFactBox.Page.al |
Displays periodically refreshed job counts. |
src/CounterManagement/Entries/PVSSMCounterEntry.Table.al |
Stores readings, deltas, and job associations. |
src/CounterManagement/Entries/PVSSMCounterEntries.Page.al |
Displays entries and assignment actions. |
src/Core/PVSSMInstall.Codeunit.al |
Enables outbound HTTP requests during installation. |
src/Core/PVSSMEvents.Codeunit.al |
Exposes a request-mocking integration event. |
src/Core/PVSSMEventHandler.Codeunit.al |
Connects collection and assignment to shop-floor events. |
src/Configuration/Setup/PVSSMSetup.Table.al |
Defines global API and session settings. |
src/Configuration/Setup/PVSSMSetup.Page.al |
Provides global configuration. |
src/Configuration/SessionParameter/PVSSMSessionParameter.Table.al |
Stores session context. |
src/Configuration/SessionLog/PVSSMSessionLog.Table.al |
Stores session lifecycle history. |
src/Configuration/SessionLog/PVSSMSessionLog.Page.al |
Displays session history and results. |
src/Configuration/SessionLog/PVSSMSessionEventType.Enum.al |
Defines start and stop event types. |
src/Configuration/CostCenter/PVSSMCostCenterSetup.Table.al |
Stores machine connection and polling settings. |
src/Configuration/CostCenter/PVSSMCostCenterSetup.Page.al |
Provides cost-center configuration and related actions. |
src/API/PVSSMOrderSheetAPI.Page.al |
Exposes read-only order-sheet data. |
Permissions/PVSSMFULL.PermissionSet.al |
Grants access to integration objects and data. |
app.json |
Defines extension metadata and dependencies. |
.vscode/settings.json |
Enables AL code analyzers. |
.vscode/launch.json |
Adds an empty debug configuration scaffold. |
Review effort: Balanced
| CounterEntry."Case ID" := in_Journal_EntryRec.ID; | ||
| CounterEntry."Plan ID" := in_Journal_EntryRec."Plan ID"; | ||
| CounterEntry.UOM := in_Journal_EntryRec."UOM"; | ||
| CounterEntry."Current Count" := -1; |
| CounterEntry.SetRange("Case ID", in_Journal_EntryRec.ID); | ||
| CounterEntry.SetRange("Plan ID", in_Journal_EntryRec."Plan ID"); | ||
| CounterEntry.SetRange(UOM, in_Journal_EntryRec."UOM"); | ||
| if CounterEntry.FindFirst() then begin |
| CounterEntry.SetRange("Cost Center Code", in_CostCenterCode); | ||
| if CounterEntry.FindLast() then | ||
| NextEntryNo := CounterEntry."Entry No." | ||
| else | ||
| NextEntryNo := 0; |
| if (CountCostCenterTxt <> '') and (JobCostingEntry."Cost Center Code" <> CountCostCenterTxt) then | ||
| Error(CostCenterMismatchErr); | ||
|
|
||
| JobCostingEntry.Validate("Quantity", JobCostingEntry."Quantity" + CountQty); |
| this.ParseXMLResponse(SubString, CounterEntry, SMCostCenterSetup); | ||
| SMCostCenterSetup.SetLastHeartbeat(); | ||
| CounterEntry.Insert(); |
| Subtype = Install; | ||
|
|
||
|
|
||
| trigger OnInstallAppPerDatabase() |
| If not this.ResolveContext() then | ||
| exit; |
| if SMCostCenterSetup.Enabled then | ||
| exit; |
|
|
||
| trigger OnBeforeInsert() | ||
| begin | ||
| this.GenerateSpencerMetricsKey(Rec); |
| this.Authenticate(SMSetup."Base URL", SMCostCenterSetup); | ||
|
|
||
| RequestUrl := this.BuildRequestUrl(SMSetup."Base URL", 'getXMLData?ApiSid=' + SMCostCenterSetup."Login Key"); | ||
| Response := this.SendGetRequest(RequestUrl, Response); |

