Skip to content

Need event - OnAfterGetNextNoInternal(var NoSeriesLine: Record "No. Series Line") #29623

@JohnsonPatrick1094

Description

@JohnsonPatrick1094

Why do you need this change?

Need event OnAfterGetNextNoInternal(var NoSeriesLine: Record "No. Series Line") in the below objects

codeunit 306 "No. Series - Stateless Impl." implements "No. Series - Single"
Function GetNextNoInternal, before the code exit(NoSeriesLine."Last No. Used");

[InherentPermissions(PermissionObjectType::TableData, Database::"No. Series Line", 'm')]
local procedure GetNextNoInternal(var NoSeriesLine: Record "No. Series Line"; ModifySeries: Boolean; UsageDate: Date; HideErrorsAndWarnings: Boolean): Code[20]
begin
if NoSeriesLine."Last No. Used" = '' then begin
if HideErrorsAndWarnings and (NoSeriesLine."Starting No." = '') then
exit('');
NoSeriesLine.TestField("Starting No.");
NoSeriesLine."Last No. Used" := NoSeriesLine."Starting No.";
end else
if NoSeriesLine."Increment-by No." <= 1 then
NoSeriesLine."Last No. Used" := IncStr(NoSeriesLine."Last No. Used")
else
NoSeriesLine."Last No. Used" := IncStr(NoSeriesLine."Last No. Used", NoSeriesLine."Increment-by No.");

    if not EnsureLastNoUsedIsWithinValidRange(NoSeriesLine, HideErrorsAndWarnings) then
        exit('');

    if ModifySeries then begin
        NoSeriesLine."Last Date Used" := UsageDate;
        NoSeriesLine.Validate(Open);
        NoSeriesLine.Modify();
    end;
    **OnAfterGetNextNoInternal(var NoSeriesLine: Record "No. Series Line")**

    exit(NoSeriesLine."Last No. Used");
end;

codeunit 307 "No. Series - Sequence Impl." implements "No. Series - Single"
In the function, GetNextNoInternal

local procedure GetNextNoInternal(var NoSeriesLine: Record "No. Series Line"; ModifySeries: Boolean; UsageDate: Date; HideErrorsAndWarnings: Boolean): Code[20]
var
NoSeriesLine2: Record "No. Series Line";
NoSeriesStatelessImpl: Codeunit "No. Series - Stateless Impl.";
NewNo: BigInteger;
begin
if NoSeriesLine.IsTemporary() or (NoSeriesLine."Temp Current Sequence No." <> 0) then begin // Do not update the database for temporary records, if Temp Current Sequence No. is set that means we are emulating the next numbers
if NoSeriesLine."Temp Current Sequence No." = 0 then
NoSeriesLine."Temp Current Sequence No." := GetCurrentSequenceNo(NoSeriesLine);

        NewNo := NoSeriesLine."Temp Current Sequence No." + NoSeriesLine."Increment-by No.";

        if ModifySeries then
            NoSeriesLine."Temp Current Sequence No." := NewNo;
    end else
        if not TryGetNextSequenceNo(NoSeriesLine, ModifySeries, NewNo) then begin
            if not NumberSequence.Exists(NoSeriesLine."Sequence Name") then
                CreateNewSequence(NoSeriesLine);
            TryGetNextSequenceNo(NoSeriesLine, ModifySeries, NewNo);
        end;

    NoSeriesLine2 := NoSeriesLine;
    NoSeriesLine2."Last No. Used" := GetFormattedNo(NoSeriesLine, NewNo);
    NoSeriesLine2.Validate(Open);

    if not NoSeriesStatelessImpl.EnsureLastNoUsedIsWithinValidRange(NoSeriesLine2, HideErrorsAndWarnings) then
        exit('');

    if ModifySeries and ((NoSeriesLine."Last Date Used" <> UsageDate) or (NoSeriesLine.Open <> NoSeriesLine2.Open) or NoSeriesLine.IsTemporary()) then begin // Only modify the series if either the date or the open status has changed. Otherwise avoid locking the record.
        NoSeriesLine."Last Date Used" := UsageDate;
        NoSeriesLine.Open := NoSeriesLine2.Open;
        NoSeriesLine.Modify(true);
    end;

   **OnAfterGetNextNoInternal(var NoSeriesLine: Record "No. Series Line")**
    exit(NoSeriesLine2."Last No. Used");
end;

efore

Describe the request

I need to change the No Series Line."Last No. Used" field before the function GetNextNoInternal is returned to the calling function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions