KVSKBANoSeriesMgt#
Procedures#
GetNextNo(Code[20], Code[20], Date, Boolean, Code[20], Code[20]) :#
Summary: Returns a new number and the used number series by utilizing the standard codeunit "No. Series". UsedNoSeries takes priority in getting the next new number. If there is no valid UsedNoSeries, DefaultNoSeries will be used.
procedure GetNextNo(DefaultNoSeries: Code[20]; UsedNoSeries: Code[20]; UsageDate: Date; HideErrorsAndWarnings: Boolean; var NewNoSeries: Code[20]; var NewNo: Code[20]):
Parameters:
DefaultNoSeries: The Number Series Code located in the corresponding setup tableUsedNoSeries: The Number Series Code located in the same table the new number is forUsageDate: The date of retrieval, this will influence which line is usedHideErrorsAndWarnings: Whether errors should be ignoredNewNoSeries: The Number Series that is used for the new NumberNewNo: The new Number generated from the NewNoSeries
Remarks: This is the main procedure that all overloads delegate to. Priority logic: UsedNoSeries is used if not empty, otherwise DefaultNoSeries is used. The UsageDate determines which number series line is applicable based on date ranges. If HideErrorsAndWarnings is true, the procedure will not throw errors for invalid number series. Integration events OnBeforeGetNextNo and OnAfterGetNextNo are raised for extensibility.
GetNextNo(Code[20], Code[20], Boolean, Code[20], Code[20]) :#
Summary: Returns a new number and the used number series by utilizing the standard codeunit "No. Series". UsedNoSeries takes priority in getting the next new number. If there is no valid UsedNoSeries, DefaultNoSeries will be used.
procedure GetNextNo(DefaultNoSeries: Code[20]; UsedNoSeries: Code[20]; HideErrorsAndWarnings: Boolean; var NewNoSeries: Code[20]; var NewNo: Code[20]):
Parameters:
DefaultNoSeries: The Number Series Code located in the corresponding setup tableUsedNoSeries: The Number Series Code located in the same table the new number is forHideErrorsAndWarnings: Whether errors should be ignoredNewNoSeries: The Number Series that is used for the new NumberNewNo: The new Number generated from the NewNoSeries
Remarks: Overload that uses WorkDate() as the usage date. Use this when the current work date should determine which number series line to use.
GetNextNo(Code[20], Code[20], Date, Code[20], Code[20]) :#
Summary: Returns a new number and the used number series by utilizing the standard codeunit "No. Series". UsedNoSeries takes priority in getting the next new number. If there is no valid UsedNoSeries, DefaultNoSeries will be used.
procedure GetNextNo(DefaultNoSeries: Code[20]; UsedNoSeries: Code[20]; UsageDate: Date; var NewNoSeries: Code[20]; var NewNo: Code[20]):
Parameters:
DefaultNoSeries: The Number Series Code located in the corresponding setup tableUsedNoSeries: The Number Series Code located in the same table the new number is forUsageDate: The date of retrieval, this will influence which line is usedNewNoSeries: The Number Series that is used for the new NumberNewNo: The new Number generated from the NewNoSeries
Remarks: Overload that does not hide errors and warnings. Use this when you want standard error handling for invalid number series configurations. Any issues with the number series will result in an error being thrown.
GetNextNo(Code[20], Code[20], Code[20], Code[20]) :#
Summary: Returns a new number and the used number series by utilizing the standard codeunit "No. Series". UsedNoSeries takes priority in getting the next new number. If there is no valid UsedNoSeries, DefaultNoSeries will be used.
procedure GetNextNo(DefaultNoSeries: Code[20]; UsedNoSeries: Code[20]; var NewNoSeries: Code[20]; var NewNo: Code[20]):
Parameters:
DefaultNoSeries: The Number Series Code located in the corresponding setup tableUsedNoSeries: The Number Series Code located in the same table the new number is forNewNoSeries: The Number Series that is used for the new NumberNewNo: The new Number generated from the NewNoSeries
Remarks: Simplest overload that uses WorkDate() and standard error handling. Use this for typical scenarios where you need a new number with default behavior.
SetDefaultSeries(Code[20], Code[20]) :#
Summary: Sets the default series based on the provided No. Series Code.
procedure SetDefaultSeries(var NewNoSeriesCode: Code[20]; NoSeriesCode: Code[20]):
Parameters:
NewNoSeriesCode: NewNoSeriesCode to be set as default.NoSeriesCode: Existing NoSeriesCode to check for default series.
Remarks: This procedure only sets the NewNoSeriesCode if the provided NoSeriesCode is automatic. If NoSeriesCode is empty or not automatic, NewNoSeriesCode remains unchanged. Use this to automatically populate number series fields when the series allows automatic numbering. The OnBeforeSetDefaultSeries event allows customization of this behavior.
Events#
OnBeforeGetNextNo(Code[20], Code[20], Date, Boolean, Code[20], Code[20], Boolean) :#
Summary: Integration event triggered before getting the next number from a number series.
[IntegrationEvent(false, false)]
local procedure OnBeforeGetNextNo(DefaultNoSeries: Code[20]; UsedNoSeries: Code[20]; UseDate: Date; HideErrorsAndWarnings: Boolean; var NewNoSeries: Code[20]; var NewNo: Code[20]; var IsHandled: Boolean):
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBANoSeriesMgt", 'OnBeforeGetNextNo', '', false, false)]
local procedure DoSomethingOnBeforeGetNextNo(DefaultNoSeries: Code[20]; UsedNoSeries: Code[20]; UseDate: Date; HideErrorsAndWarnings: Boolean; var NewNoSeries: Code[20]; var NewNo: Code[20]; var IsHandled: Boolean)
begin
end;
Parameters:
DefaultNoSeries: The default number series code from setup.UsedNoSeries: The currently used number series code.UseDate: The date to use for determining the applicable number series line.HideErrorsAndWarnings: Whether to suppress errors and warnings.NewNoSeries: The number series that will be used (can be modified).NewNo: The new number to be generated (can be set to skip standard logic).IsHandled: Set to true to skip the standard number generation logic.
Remarks: Use this event to implement custom number generation logic or override the standard behavior. If you set IsHandled to true and provide a NewNo, the standard No. Series logic will be bypassed. You can also modify NewNoSeries to use a different number series than what would normally be selected. This is useful for implementing custom number series selection logic based on additional criteria.
OnAfterGetNextNo(Code[20], Code[20], Date, Boolean, Code[20], Code[20]) :#
Summary: Integration event triggered after getting the next number from a number series.
[IntegrationEvent(false, false)]
local procedure OnAfterGetNextNo(DefaultNoSeries: Code[20]; UsedNoSeries: Code[20]; UseDate: Date; HideErrorsAndWarnings: Boolean; var NewNoSeries: Code[20]; var NewNo: Code[20]):
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBANoSeriesMgt", 'OnAfterGetNextNo', '', false, false)]
local procedure DoSomethingOnAfterGetNextNo(DefaultNoSeries: Code[20]; UsedNoSeries: Code[20]; UseDate: Date; HideErrorsAndWarnings: Boolean; var NewNoSeries: Code[20]; var NewNo: Code[20])
begin
end;
Parameters:
DefaultNoSeries: The default number series code from setup.UsedNoSeries: The currently used number series code.UseDate: The date used for determining the applicable number series line.HideErrorsAndWarnings: Whether errors and warnings were suppressed.NewNoSeries: The number series that was used (can be modified).NewNo: The new number that was generated (can be modified).
Remarks: Use this event to perform post-processing after a number has been generated. You can modify the NewNo if you need to apply transformations or formatting. This is also useful for logging, validation, or triggering additional business logic. Note that at this point the number has already been reserved in the number series.
OnBeforeSetDefaultSeries(Code[20], Code[20], Boolean) :#
Summary: Integration event triggered before setting the default number series.
[IntegrationEvent(false, false)]
local procedure OnBeforeSetDefaultSeries(var NewNoSeriesCode: Code[20]; NoSeriesCode: Code[20]; var IsHandled: Boolean):
[EventSubscriber(ObjectType::Codeunit, Codeunit::"KVSKBANoSeriesMgt", 'OnBeforeSetDefaultSeries', '', false, false)]
local procedure DoSomethingOnBeforeSetDefaultSeries(var NewNoSeriesCode: Code[20]; NoSeriesCode: Code[20]; var IsHandled: Boolean)
begin
end;
Parameters:
NewNoSeriesCode: The number series code to be set as default (can be modified).NoSeriesCode: The number series code being evaluated.IsHandled: Set to true to skip the standard default series logic.
Remarks: Use this event to implement custom logic for determining default number series. If you set IsHandled to true, the standard check for automatic number series will be bypassed. You can modify NewNoSeriesCode to set a different number series as the default. This is useful when you have custom rules for which number series should be used by default.