Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using Microsoft.QualityManagement.Utilities;
codeunit 20405 "Qlty. Inspec. Gen. Rule Mgmt."
{
var
QltyMiscHelpers: Codeunit "Qlty. Misc Helpers";
QltyConfigurationHelpers: Codeunit "Qlty. Configuration Helpers";
QltyTraversal: Codeunit "Qlty. Traversal";
UnexpectedAndNoDetailsErr: Label 'Something unexpected went wrong trying to find a matching quality inspection generation rule. Please review your Quality Inspection source table configuration.';
CouldNotFindGenerationRuleErr: Label 'Could not find any compatible inspection generation rules for the template %1. Navigate to Quality Inspection Generation Rules and create a generation rule for the template %1', Comment = '%1=the template';
Expand Down Expand Up @@ -122,7 +122,7 @@ codeunit 20405 "Qlty. Inspec. Gen. Rule Mgmt."
Error(UnexpectedUnableWithADetailErr, Format(TargetRecordRef.RecordId()));

Found := FindFirstGenerationRuleAndRecordBasedOnRecursive(
QltyMiscHelpers.GetArbitraryMaximumRecursion(),
QltyConfigurationHelpers.GetArbitraryMaximumRecursion(),
false,
RaiseErrorIfNoRuleIsFound,
TargetRecordRef,
Expand Down Expand Up @@ -153,7 +153,7 @@ codeunit 20405 "Qlty. Inspec. Gen. Rule Mgmt."
Error(NoGenRuleErr, Format(TargetRecordRef.RecordId()));

Found := FindFirstGenerationRuleAndRecordBasedOnRecursive(
QltyMiscHelpers.GetArbitraryMaximumRecursion(),
QltyConfigurationHelpers.GetArbitraryMaximumRecursion(),
true,
IsManualCreation,
TargetRecordRef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ codeunit 20410 "Qlty. Result Evaluation"
TableNo = "Qlty. Inspection Line";

var
QltyLocalization: Codeunit "Qlty. Localization";
IsDefaultNumberTok: Label '<>0', Locked = true;
IsDefaultTextTok: Label '<>''''', Locked = true;
InvalidDataTypeErr: Label 'The value "%1" is not allowed for %2, it is not a %3.', Comment = '%1=the value, %2=field name,%3=field type.';
Expand Down Expand Up @@ -378,16 +379,13 @@ codeunit 20410 "Qlty. Result Evaluation"
QltyTestValueType::"Value Type Boolean":
begin
if not (IsBlankOrEmptyCondition(AllowableValues) and (TextToValidate = '')) then
if QltyMiscHelpers.GetBooleanFor(TextToValidate) then
TextToValidate := QltyMiscHelpers.GetTranslatedYes250()
else
TextToValidate := QltyMiscHelpers.GetTranslatedNo250();
TextToValidate := QltyLocalization.FormatForUser(QltyMiscHelpers.GetBooleanFor(TextToValidate));

if (AllowableValues <> '') and (QltyMiscHelpers.CanTextBeInterpretedAsBooleanIsh(AllowableValues)) then begin
if not QltyMiscHelpers.GetBooleanFor(TextToValidate) = QltyMiscHelpers.GetBooleanFor(AllowableValues) then
Error(NotInAllowableValuesErr, TextToValidate, NumberOrNameOfTestNameForError, AllowableValues);
end else
if not (TextToValidate in [QltyMiscHelpers.GetTranslatedYes250(), QltyMiscHelpers.GetTranslatedNo250(), '']) then
if not (TextToValidate in [QltyLocalization.GetTranslatedYes(), QltyLocalization.GetTranslatedNo(), '']) then
Error(NotInAllowableValuesErr, TextToValidate, NumberOrNameOfTestNameForError, AllowableValues);
end;
QltyTestValueType::"Value Type Text":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ using System.Reflection;
codeunit 20408 "Qlty. Traversal"
{
var
QltyConfigurationHelpers: Codeunit "Qlty. Configuration Helpers";
QltyMiscHelpers: Codeunit "Qlty. Misc Helpers";
ControlInfoToVisibility: Dictionary of [Text, Boolean];
ControlInfoToCaptionClass: Dictionary of [Text, Text];
Expand Down Expand Up @@ -122,7 +123,7 @@ codeunit 20408 "Qlty. Traversal"
/// <returns>True if at least one possible target configuration was found; False otherwise</returns>
internal procedure FindPossibleTargetsBasedOnConfigRecursive(InputTable: Integer; var TempAvailableQltyInspectSourceConfig: Record "Qlty. Inspect. Source Config." temporary): Boolean
begin
exit(FindPossibleTargetsBasedOnConfigRecursiveWithList(QltyMiscHelpers.GetArbitraryMaximumRecursion(), InputTable, TempAvailableQltyInspectSourceConfig));
exit(FindPossibleTargetsBasedOnConfigRecursiveWithList(QltyConfigurationHelpers.GetArbitraryMaximumRecursion(), InputTable, TempAvailableQltyInspectSourceConfig));
end;

local procedure FindPossibleTargetsBasedOnConfigRecursiveWithList(CurrentRecursionDepth: Integer; InputTable: Integer; var TempAvailableQltyInspectSourceConfig: Record "Qlty. Inspect. Source Config." temporary) Found: Boolean
Expand Down Expand Up @@ -215,7 +216,7 @@ codeunit 20408 "Qlty. Traversal"
if TemporaryInspectionMatchRecordRef.Insert(false) then;
QltyInspectionHeader.SetIsCreating(true);
CouldApply := ApplySourceRecursive(
QltyMiscHelpers.GetArbitraryMaximumRecursion(),
QltyConfigurationHelpers.GetArbitraryMaximumRecursion(),
TemporaryInspectionMatchRecordRef,
TempAvailableQltyInspectSourceConfig,
QltyInspectionHeader,
Expand Down Expand Up @@ -476,7 +477,7 @@ codeunit 20408 "Qlty. Traversal"
OFFromTableIds.Add(InputQltyInspectionHeader."Source RecordId 4".TableNo());

foreach FromTableIterator in OFFromTableIds do begin
TestText := GetSourceFieldInfoFromChain(ListOfConsideredSourceRecords, QltyMiscHelpers.GetArbitraryMaximumRecursion(), FromTableIterator, InputTable, SourceField."No.", BackupFieldCaption);
TestText := GetSourceFieldInfoFromChain(ListOfConsideredSourceRecords, QltyConfigurationHelpers.GetArbitraryMaximumRecursion(), FromTableIterator, InputTable, SourceField."No.", BackupFieldCaption);
if TestText <> '' then
break;
end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ page 20467 "Qlty. Test Expr. Card Part"
var
QltyTest: Record "Qlty. Test";
QltyResultConditionMgmt: Codeunit "Qlty. Result Condition Mgmt.";
QltyMiscHelpers: Codeunit "Qlty. Misc Helpers";
QltyValueParsing: Codeunit "Qlty. Value Parsing";
MatrixSourceRecordId: array[10] of RecordId;
Visible1: Boolean;
Visible2: Boolean;
Expand Down Expand Up @@ -523,7 +523,7 @@ page 20467 "Qlty. Test Expr. Card Part"

QltyResultConditionMgmt.GetPromotedResultsForTest(QltyTest, MatrixSourceRecordId, MatrixArrayConditionCellData, MatrixArrayConditionDescriptionCellData, MatrixArrayCaptionSet, MatrixVisibleState);
for Iterator := 1 to ArrayLen(MatrixArrayConditionCellData) do
QltyMiscHelpers.AttemptSplitSimpleRangeIntoMinMax(MatrixArrayConditionCellData[Iterator], MatrixMinValue[Iterator], MatrixMaxValue[Iterator]);
QltyValueParsing.AttemptSplitSimpleRangeIntoMinMax(MatrixArrayConditionCellData[Iterator], MatrixMinValue[Iterator], MatrixMaxValue[Iterator]);

Visible1 := MatrixVisibleState[1];
Visible2 := MatrixVisibleState[2];
Expand All @@ -543,7 +543,7 @@ page 20467 "Qlty. Test Expr. Card Part"
begin
QltyIResultConditConf.Get(MatrixSourceRecordId[MatrixField]);
QltyIResultConditConf.Validate(Condition, MatrixArrayConditionCellData[MatrixField]);
QltyMiscHelpers.AttemptSplitSimpleRangeIntoMinMax(QltyIResultConditConf.Condition, MatrixMinValue[MatrixField], MatrixMaxValue[MatrixField]);
QltyValueParsing.AttemptSplitSimpleRangeIntoMinMax(QltyIResultConditConf.Condition, MatrixMinValue[MatrixField], MatrixMaxValue[MatrixField]);
QltyIResultConditConf.Modify(true);
LoadExistingTest(QltyTest.Code, true);
CurrPage.Update(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ page 20434 "Qlty. Test Number Card Part"
var
QltyTest: Record "Qlty. Test";
QltyResultConditionMgmt: Codeunit "Qlty. Result Condition Mgmt.";
QltyMiscHelpers: Codeunit "Qlty. Misc Helpers";
QltyValueParsing: Codeunit "Qlty. Value Parsing";
MatrixSourceRecordId: array[10] of RecordId;
Visible1: Boolean;
Visible2: Boolean;
Expand Down Expand Up @@ -1096,7 +1096,7 @@ page 20434 "Qlty. Test Number Card Part"
if QltyTest."Wizard Internal" = QltyTest."Wizard Internal"::"In Progress" then
AdvancedRange := DefaultRangeTok;

if QltyMiscHelpers.AttemptSplitSimpleRangeIntoMinMax(AdvancedRange, MinAllowed, MaxAllowed) then begin
if QltyValueParsing.AttemptSplitSimpleRangeIntoMinMax(AdvancedRange, MinAllowed, MaxAllowed) then begin
if not QltyTestIds.Contains(QltyTest.Code) then
RangeNumberType := RangeNumberType::"A range of numbers";
end else
Expand Down Expand Up @@ -1225,7 +1225,7 @@ page 20434 "Qlty. Test Number Card Part"

QltyResultConditionMgmt.GetPromotedResultsForTest(QltyTest, MatrixSourceRecordId, MatrixArrayConditionCellData, MatrixArrayConditionDescriptionCellData, MatrixArrayCaptionSet, MatrixVisibleState);
for Iterator := 1 to ArrayLen(MatrixArrayConditionCellData) do
QltyMiscHelpers.AttemptSplitSimpleRangeIntoMinMax(MatrixArrayConditionCellData[Iterator], MatrixMinValue[Iterator], MatrixMaxValue[Iterator]);
QltyValueParsing.AttemptSplitSimpleRangeIntoMinMax(MatrixArrayConditionCellData[Iterator], MatrixMinValue[Iterator], MatrixMaxValue[Iterator]);

Visible1 := MatrixVisibleState[1];
Visible2 := MatrixVisibleState[2];
Expand All @@ -1245,7 +1245,7 @@ page 20434 "Qlty. Test Number Card Part"
begin
QltyIResultConditConf.Get(MatrixSourceRecordId[Matrix]);
QltyIResultConditConf.Validate(Condition, MatrixArrayConditionCellData[Matrix]);
QltyMiscHelpers.AttemptSplitSimpleRangeIntoMinMax(QltyIResultConditConf.Condition, MatrixMinValue[Matrix], MatrixMaxValue[Matrix]);
QltyValueParsing.AttemptSplitSimpleRangeIntoMinMax(QltyIResultConditConf.Condition, MatrixMinValue[Matrix], MatrixMaxValue[Matrix]);
QltyIResultConditConf.Modify(true);
LoadExistingTest(QltyTest.Code);
CurrPage.Update(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ page 20431 "Qlty. Most Recent Picture"

trigger OnAction()
var
QltyMiscHelpers: Codeunit "Qlty. Misc Helpers";
QltyFileImport: Codeunit "Qlty. File Import";
InStream: InStream;
begin
if Rec."Most Recent Picture".HasValue() then
if not Confirm(OverrideImageQst) then
exit;
Clear(Rec."Most Recent Picture");
if QltyMiscHelpers.PromptAndImportIntoInStream(FileFilterTok, InStream) then begin
if QltyFileImport.PromptAndImportIntoInStream(FileFilterTok, InStream) then begin
Rec."Most Recent Picture".ImportStream(InStream, ImageTok);
Rec.Modify();
end;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.QualityManagement.Utilities;

using Microsoft.QualityManagement.Setup;

codeunit 20597 "Qlty. Configuration Helpers"
{
/// <summary>
/// The maximum recursion to use when creating inspections.
/// Used for traversal on source table configuration when finding applicable generation rules, and also when populating source fields.
///
/// This limit prevents infinite loops in complex configuration hierarchies and ensures reasonable performance
/// when traversing multi-level table relationships.
/// </summary>
/// <returns>The maximum recursion depth allowed (currently 20 levels)</returns>
procedure GetArbitraryMaximumRecursion(): Integer
begin
exit(20);
end;

/// <summary>
/// Returns the maximum number of rows to show in field lookup dialogs.
/// Uses setup configuration if defined, otherwise defaults to 100.
///
/// Lookup order:
/// 1. OnBeforeGetDefaultMaximumRowsToShowInLookup event (if handled)
/// 2. Qlty. Management Setup."Max Rows Field Lookups" (if > 0)
/// 3. Default value of 100
/// </summary>
/// <returns>Maximum number of rows for field lookups</returns>
procedure GetDefaultMaximumRowsFieldLookup() ResultRowsCount: Integer
var
QltyManagementSetup: Record "Qlty. Management Setup";
Handled: Boolean;
begin
ResultRowsCount := 100;
OnBeforeGetDefaultMaximumRowsToShowInLookup(ResultRowsCount, Handled);
if Handled then
exit;

if not QltyManagementSetup.GetSetupRecord() then
exit;

if QltyManagementSetup."Max Rows Field Lookups" > 0 then
ResultRowsCount := QltyManagementSetup."Max Rows Field Lookups";
end;

/// <summary>
/// Provides an opportunity for customizations to alter the default maximum rows shown
/// for a table lookup in a quality inspector field.
/// Changing the default to a larger number can introduce performance issues.
/// </summary>
/// <param name="Rows">The number of rows to show</param>
/// <param name="Handled">Set to true if the event was handled</param>
[IntegrationEvent(false, false)]
local procedure OnBeforeGetDefaultMaximumRowsToShowInLookup(var Rows: Integer; var Handled: Boolean)
begin
end;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.QualityManagement.Utilities;

codeunit 20596 "Qlty. File Import"
{
var
ImportFromLbl: Label 'Import From File';

/// <summary>
/// Prompts the user to select a file and imports its contents into an InStream for processing.
/// Displays a file upload dialog with optional file type filtering.
///
/// Common usage: Importing configuration files, test data, or external quality inspection results.
/// </summary>
/// <param name="FilterString">File type filter for the upload dialog (e.g., "*.xml|*.txt")</param>
/// <param name="InStream">Output: InStream containing the uploaded file contents</param>
/// <returns>True if file was successfully selected and uploaded; False if user cancelled or upload failed</returns>
procedure PromptAndImportIntoInStream(FilterString: Text; var InStream: InStream): Boolean
var
ServerFile: Text;
begin
exit(UploadIntoStream(ImportFromLbl, '', FilterString, ServerFile, InStream));
end;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------
namespace Microsoft.QualityManagement.Utilities;

codeunit 20598 "Qlty. Localization"
{
var
TranslatableYesLbl: Label 'Yes';
TranslatableNoLbl: Label 'No';

/// <summary>
/// Returns the translatable "Yes" label with maximum length of 250 characters.
/// Used for UI display and user-facing text where localization is required.
/// </summary>
/// <returns>The localized "Yes" text (up to 250 characters)</returns>
procedure GetTranslatedYes(): Text[250]
Copy link
Contributor

Choose a reason for hiding this comment

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

Will we keep this pattern? We don't use it in base app, we just rely on regular labels directly in the codeunit that needs them

begin
exit(TranslatableYesLbl);
end;

/// <summary>
/// Returns the translatable "No" label with maximum length of 250 characters.
/// Used for UI display and user-facing text where localization is required.
/// </summary>
/// <returns>The localized "No" text (up to 250 characters)</returns>
procedure GetTranslatedNo(): Text[250]
begin
exit(TranslatableNoLbl);
end;

/// <summary>
/// Formats a boolean value for user display using localized Yes/No text.
/// </summary>
/// <param name="Value">The boolean value to format</param>
/// <returns>Localized "Yes" for true, "No" for false</returns>
procedure FormatForUser(Value: Boolean): Text[250]
begin
if Value then
exit(TranslatableYesLbl);
exit(TranslatableNoLbl);
end;
}
Loading
Loading