-
Notifications
You must be signed in to change notification settings - Fork 319
Open
Labels
ApprovedThe issue is approvedThe issue is approvedSCMGitHub request for SCM areaGitHub request for SCM area
Description
Describe the issue
ISSUE 6.8: No Pre-Condition Validation in OnModify Trigger
Severity: HIGH
Category: Validation & Data Integrity
Files: src/Document/QltyInspectionTestLine.Table.al
Problem:
The OnModify trigger attempts numeric conversion but doesn't validate the test line state or status before modification.
Code Location (Lines 218-226):
trigger OnModify()
begin
if not Rec.IsTemporary() then
TestStatusOpen(); // Only checks if test is open
Rec."Numeric Value" := 0;
if Evaluate(Rec."Numeric Value", Rec."Test Value") then; // DEFECT: Ignored result
end;Issues:
- Silent Failure: Evaluate result ignored - "Numeric Value" stays 0 if conversion fails
- No Field Validation: Doesn't check if "Test Value" field type is numeric
- No Error Message: User has no idea conversion failed
Scenarios:
// SCENARIO 1: Text field treated as numeric
Field Type = "Text"
Test Value = "Some text"
OnModify: Evaluate fails silently
Numeric Value = 0 (wrong - should be null or error)
// SCENARIO 2: Invalid numeric format
Field Type = "Integer"
Test Value = "12.5.7" // Invalid
OnModify: Evaluate fails silently
Numeric Value = 0 (wrong - should show error)
// SCENARIO 3: Overflow
Field Type = "Integer"
Test Value = "999999999999999" // Exceeds integer max
OnModify: Evaluate fails silently
Numeric Value = 0 (wrong - data loss)Recommended Fix:
trigger OnModify()
var
ConversionSuccess: Boolean;
begin
if not Rec.IsTemporary() then
TestStatusOpen();
// Only attempt numeric conversion for numeric field types
Rec.CalcFields("Field Type");
if Rec."Field Type" in [Rec."Field Type"::"Field Type Decimal", Rec."Field Type"::"Field Type Integer"] then begin
Rec."Numeric Value" := 0;
if Rec."Test Value" <> '' then begin
ClearLastError();
ConversionSuccess := Evaluate(Rec."Numeric Value", Rec."Test Value");
if not ConversionSuccess then
Error(InvalidNumericValueErr, Rec."Test Value", Rec."Field Code", Rec."Field Type");
end;
end else
Rec."Numeric Value" := 0; // Clear for non-numeric types
end;
var
InvalidNumericValueErr: Label 'The value "%1" is not a valid %3 for field "%2". Please enter a valid numeric value.', Comment = '%1=entered value, %2=field code, %3=field type';Expected behavior
Steps to reproduce
Additional context
I will provide a fix for a bug
- I will provide a fix for a bug
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ApprovedThe issue is approvedThe issue is approvedSCMGitHub request for SCM areaGitHub request for SCM area