[Quality Management] Add Quality Inspection Result card#8358
[Quality Management] Add Quality Inspection Result card#8358JakovljevicDusan wants to merge 4 commits into
Conversation
| else | ||
| Rec."Evaluation Sequence" := ExistingQltyInspectionResult."Evaluation Sequence" + 1; | ||
|
|
||
| ValidateEvaluationSequenceNotUsedElsewhere(); |
There was a problem hiding this comment.
Redundant uniqueness query inside sequence setter
SetDefaultEvaluationSequence already computes max + 1, which is unique at the moment of reading; the immediate call to ValidateEvaluationSequenceNotUsedElsewhere() issues an extra database query for a condition that cannot normally be true, and produces a confusing error for the user if a race condition happens between the two operations.
Recommendation:
- Remove the
ValidateEvaluationSequenceNotUsedElsewhere()call fromSetDefaultEvaluationSequence. Uniqueness is already enforced byOnInsertRecordandOnModifyRecordtriggers on both pages.
| ValidateEvaluationSequenceNotUsedElsewhere(); | |
| internal procedure SetDefaultEvaluationSequence() | |
| var | |
| ExistingQltyInspectionResult: Record "Qlty. Inspection Result"; | |
| begin | |
| ExistingQltyInspectionResult.SetCurrentKey("Evaluation Sequence"); | |
| ExistingQltyInspectionResult.Ascending(false); | |
| if not ExistingQltyInspectionResult.FindFirst() then | |
| Rec."Evaluation Sequence" := 0 | |
| else | |
| Rec."Evaluation Sequence" := ExistingQltyInspectionResult."Evaluation Sequence" + 1; | |
| end; |
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| Rec.ValidateEvaluationSequenceNotUsedElsewhere(); | ||
| end; | ||
|
|
||
| trigger OnModifyRecord(): Boolean |
There was a problem hiding this comment.
OnModifyRecord missing exit(true), blocks modifications
Without an explicit exit(true), the Boolean return of OnModifyRecord defaults to false, which causes the platform to discard every record modification made on the card page after validation runs.
Recommendation:
- Add
exit(true);as the last statement of the trigger so the modification proceeds when validation passes.
| trigger OnModifyRecord(): Boolean | |
| trigger OnModifyRecord(): Boolean | |
| begin | |
| Rec.ValidateEvaluationSequenceNotUsedElsewhere(); | |
| exit(true); | |
| end; |
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| /// <summary> | ||
| /// Validates that the evaluation sequence is not used by another result. | ||
| /// </summary> | ||
| internal procedure ValidateEvaluationSequenceNotUsedElsewhere() |
There was a problem hiding this comment.
Application-only uniqueness check is race-prone
The ValidateEvaluationSequenceNotUsedElsewhere procedure checks uniqueness of Evaluation Sequence only at the application level, with no database-level unique constraint. Two concurrent sessions can both pass the check (finding no conflict) before either commits, resulting in duplicate evaluation sequences that silently violate the intended invariant.
Recommendation:
- Add a unique key on the
Evaluation Sequencefield in the table definition so the database enforces uniqueness at the storage level, in addition to the application-level validation.
| internal procedure ValidateEvaluationSequenceNotUsedElsewhere() | |
| // In QltyInspectionResult.Table.al, add a unique key: | |
| keys | |
| { | |
| key(EvaluationSequenceKey; "Evaluation Sequence") | |
| { | |
| Unique = true; | |
| } | |
| } |
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
| Error(MustChangePriorityErr, ExistingQltyInspectionResult.Code, ExistingQltyInspectionResult.Description); | ||
| end; | ||
|
|
||
| /// <summary> |
There was a problem hiding this comment.
Method doc comment overpromises implementation
The XML doc comment for UpdateTestsTemplatesAndInspections states it "adjusts evaluation sequences, and updates promoted results", but the body only calls CopyGradeConditionsFromDefaultToAllTemplates(). Either the implementation is incomplete or the documentation is incorrect, which will mislead callers.
Recommendation:
- Align the doc comment with the actual implementation, or implement the missing behavior (sequence adjustment and promoted result updates) described in the summary.
| /// <summary> | |
| /// <summary> | |
| /// Copies grade conditions from the default template to all quality templates and inspections. | |
| /// </summary> | |
| internal procedure UpdateTestsTemplatesAndInspections() | |
| var | |
| QltyResultConditionMgmt2: Codeunit "Qlty. Result Condition Mgmt."; | |
| begin | |
| QltyResultConditionMgmt2.CopyGradeConditionsFromDefaultToAllTemplates(); | |
| end; |
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why
What & why
Add card page to make it easier to show all settings.
Linked work
Fixes AB#636815