Skip to content

[Quality Management] Add Quality Inspection Result card#8358

Open
JakovljevicDusan wants to merge 4 commits into
mainfrom
bugs/QM-AddQltyInspectionResultCard
Open

[Quality Management] Add Quality Inspection Result card#8358
JakovljevicDusan wants to merge 4 commits into
mainfrom
bugs/QM-AddQltyInspectionResultCard

Conversation

@JakovljevicDusan
Copy link
Copy Markdown
Contributor

@JakovljevicDusan JakovljevicDusan commented May 27, 2026

What & why

Add card page to make it easier to show all settings.

Linked work

Fixes AB#636815

@JakovljevicDusan JakovljevicDusan requested a review from a team as a code owner May 27, 2026 15:32
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label May 27, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone May 27, 2026
@JakovljevicDusan JakovljevicDusan enabled auto-merge (squash) May 28, 2026 08:12
else
Rec."Evaluation Sequence" := ExistingQltyInspectionResult."Evaluation Sequence" + 1;

ValidateEvaluationSequenceNotUsedElsewhere();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

$\textbf{🟡\ Medium\ Severity\ —\ Performance} \quad \color{gray}{\texttt{\small Iteration\ 1}}$

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 from SetDefaultEvaluationSequence. Uniqueness is already enforced by OnInsertRecord and OnModifyRecord triggers on both pages.
Suggested change
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

$\textbf{🟠\ High\ Severity\ —\ Style} \quad \color{gray}{\texttt{\small Iteration\ 1}}$

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.
Suggested change
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()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

$\textbf{🟠\ High\ Severity\ —\ Performance} \quad \color{gray}{\texttt{\small Iteration\ 1}}$

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 Sequence field in the table definition so the database enforces uniqueness at the storage level, in addition to the application-level validation.
Suggested change
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>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

$\textbf{🟡\ Medium\ Severity\ —\ Style} \quad \color{gray}{\texttt{\small Iteration\ 1}}$

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.
Suggested change
/// <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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant