[Event Request] codeunit 306 "No. Series - Stateless Impl."
Describe the request
[Event Request] codeunit 306 "No. Series - Stateless Impl." ??? OnAfterGetNextNo
Could we please have a publisher OnAfterGetNextNo in function GetNextNoInternal in Codeunit 304 "No. Series - Impl."?
[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]
var
NoSeriesSetup: Codeunit "No. Series - Setup";
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" := NoSeriesSetup.IncrementNoText(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;
//>>>>
OnAfterGetNextNo(NoSeriesLine, ModifySeries);
//<<<<
exit(NoSeriesLine."Last No. Used");
end;
//>>>>
[IntegrationEvent(false, false)]
local procedure OnAfterGetNextNo(var NoSeriesLine: Record "No. Series Line"; ModifySeries: Boolean)
begin
end;
//<<<<
Additional context
So we can have the same functionality we had in NoSeriesManagement Internal work item: AB#527178
@onzema Can you explain the scenario you need the event for? Before accepting an event I want to understand what it is you are trying to achieve so we can evaluate whether an event is the best solution for everyone.
Also, Business Foundation is open source and open for contribution so this issue should be moved to https://github.com/microsoft/BCApps/ Before creating a PR your issue must be accepted. Do not create a PR just yet, lets discuss solutions first.
Hello @grobyns my scenario is a series that has this format %1%2XXXXXX where %1 the year and %2 weeks number. then XXXXXX is the number that gets incremented so we could have a series that looks like this 2401000001 -> year 2024, week 1 2402000002 -> year 2024, week 2 2402000003 -> year 2024, week 2 2403000004 -> year 2024, week 3
we could achieve this format the way series were handled before because just before exiting the function with the new value we had an event
Sounds to me like you could add a No. Series Line per week and set up the dates correctly to get the same result. You probably don't want to do that manually but I think it's better than manipulating the string after we've generated a new number from the No. Series.
it's not the same setting up the dates correctly. first week it would be the same 2401000001 -> 2401000001 but after that it would'nt 2402000002 -> 2402000001 2402000003 -> 2402000002 and it would get worse 2403000004 -> 2403000001
so the standard functionallity doesn't work
In that case I'd recommend taking a look at implementing your own version of the interface "No. Series - Single". You can create an implementation which will prefix year/week and set up which implementation to use on the No. Series line(s) so it only applies to those No Series where you need this prefix.
I didn't think about that option. I've tried and i get this error. i need to replicate this codeunit as well or there's a work around to avoid this?
thank you!
Right now there's no interface for the "No. Series - Errors Impl.", it would be great to add one, though we may want to change it a bit first, such as allowing you to add multiple actionable elements, furthermore you may want to get the actionable error in order to do something more specific with it. For now I would duplicate the functionality you need from here. If you are up for it, you can of course contribute an interface but there will probably be a bunch of feedback on how the interface should look, which includes re-writing the existing calls.
okey. Thank you all for your help!