Skip to content

Commit

Permalink
New Event OnSetNoSeriesLineFilters for Filter NoSeriesLine Replaces t…
Browse files Browse the repository at this point in the history
…he backwards compatible Event
  • Loading branch information
PeterDurrer committed Nov 19, 2024
1 parent 1c346ae commit f4a8e9f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ codeunit 305 "No. Series - Setup Impl."
NumberFormatErr: Label 'The number format in %1 must be the same as the number format in %2.', Comment = '%1=No. Series Code,%2=No. Series Code';
UnIncrementableStringErr: Label 'The value in the %1 field must have a number so that we can assign the next number in the series.', Comment = '%1 = New Field Name';
NumberLengthErr: Label 'The number %1 cannot be extended to more than 20 characters.', Comment = '%1=No.';
CodeFieldChangedErr: Label 'The filter on Series Code was altered by an event subscriber. This is a programming error. Please contact your partner to resolve the issue.\Original Series Code: %1\Modified Filter: %2';

procedure SetImplementation(var NoSeries: Record "No. Series"; Implementation: Enum "No. Series Implementation")
var
Expand Down Expand Up @@ -98,7 +99,7 @@ codeunit 305 "No. Series - Setup Impl."
#endif
begin
NoSeriesLine.Reset();
GetNoSeriesLineFilters(NoSeriesLine, NoSeriesRec.Code, WorkDate());
SetNoSeriesLineFilters(NoSeriesLine, NoSeriesRec.Code, WorkDate());
#if not CLEAN24
#pragma warning disable AL0432
NoSeriesManagement.RaiseObsoleteOnNoSeriesLineFilterOnBeforeFindLast(NoSeriesLine);
Expand Down Expand Up @@ -135,18 +136,17 @@ codeunit 305 "No. Series - Setup Impl."
exit(NoSeriesSingle.MayProduceGaps());
end;

local procedure GetNoSeriesLineFilters(var NoSeriesLine: Record "No. Series Line"; NoSeriesCode: Code[20]; StartingDate: Date)
internal procedure SetNoSeriesLineFilters(var NoSeriesLine: Record "No. Series Line"; NoSeriesCode: Code[20]; StartingDate: Date)
var
NoSeries: Codeunit "No. Series";
NoSeriesLine2: Record "No. Series Line";
CodeFieldChangedErr: Label 'Change of Series Code Field is on this Record not allowed.';
begin
NoSeriesLine2.SetCurrentKey("Series Code", "Starting Date");
NoSeriesLine2.SetRange("Starting Date", 0D, StartingDate);
NoSeriesLine2.SetRange("Series Code", NoSeriesCode);
RaiseSetAdditionalNoSeriesLineFilters(NoSeriesLine2);
If NoSeriesLine2."Series Code" <> NoSeriesCode then
Error(CodeFieldChangedErr); // Extensions should never change the code field range, this is a bug that developers should know immediately.
NoSeries.OnSetNoSeriesLineFilters(NoSeriesLine2);
If NoSeriesLine2.GetFilter("Series Code") <> NoSeriesCode then
Error(CodeFieldChangedErr, NoSeriesCode, NoSeriesLine2.GetFilter("Series Code")); // Extensions should never change the code field range, this is a bug that developers should know immediately.

NoSeriesLine.SetCurrentKey("Series Code", "Starting Date");
NoSeriesLine.CopyFilters(NoSeriesLine2);
Expand Down Expand Up @@ -404,9 +404,4 @@ codeunit 305 "No. Series - Setup Impl."
if NumberSequence.Exists(Rec."Sequence Name") then
NumberSequence.Delete(Rec."Sequence Name");
end;

[IntegrationEvent(false, false)]
internal procedure RaiseSetAdditionalNoSeriesLineFilters(var NoSeriesLine: Record "No. Series Line");
begin
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,11 @@ codeunit 310 "No. Series"
end;

/// <summary>
/// Use this event to change the filters set on the No. Series Line record. These filters are used when searching the No. Series.
/// Use this event to set additional filters set on the No. Series Line record. These filters are used when searching the No. Series.
/// </summary>
/// <param name="NoSeriesLine">The No. Series Line to set filters on.</param>
[IntegrationEvent(false, false)]
internal procedure OnGetNoSeriesLineOnBeforeFindLast(var NoSeriesLine: Record "No. Series Line");
internal procedure OnSetNoSeriesLineFilters(var NoSeriesLine: Record "No. Series Line");
begin
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ codeunit 304 "No. Series - Impl."
NoSeriesRec: Record "No. Series";
NoSeriesLine2: Record "No. Series Line";
NoSeries: Codeunit "No. Series";
NoSeriesSetupImpl: Codeunit "No. Series - Setup Impl.";
NoSeriesErrorsImpl: Codeunit "No. Series - Errors Impl.";
#if not CLEAN24
#pragma warning disable AL0432
Expand All @@ -174,10 +175,7 @@ codeunit 304 "No. Series - Impl."

// Find the No. Series Line closest to the usage date
NoSeriesLine2.Reset();
NoSeriesLine2.SetCurrentKey("Series Code", "Starting Date");
NoSeriesLine2.SetRange("Series Code", NoSeriesCode);
NoSeriesLine2.SetRange("Starting Date", 0D, UsageDate);
NoSeries.OnGetNoSeriesLineOnBeforeFindLast(NoSeriesLine2);
NoSeriesSetupImpl.SetNoSeriesLineFilters(NoSeriesLine2, NoSeriesCode, UsageDate);
#if not CLEAN24
#pragma warning disable AL0432
NoSeriesManagement.RaiseObsoleteOnNoSeriesLineFilterOnBeforeFindLast(NoSeriesLine2);
Expand Down

0 comments on commit f4a8e9f

Please sign in to comment.