Why do you need this change?
We need an event in CreateProdOrderLine procedure in order to manage the Item case with custom code.
In particular, we need to be able to assign a value to the parameter ErrorOccured, according to custom logics.
The OnCreateProdOrderLineOnBeforeInitProdOrderLine event is not sufficient for my scenario, since I don't have ErrorOccured as parameter to handle, moreover it is not possible to skip the code below using this event. So the ProdOrderLine record wouyld be initializate twice if I cannot skip it.
So the IsHandled parameter management is necessary.
The OnAfterProdOrderLineInsert event is not sufficient for my scenario, since I don't have ErrorOccured as parameter to handle.
Describe the request
In procedure CreateProdOrderLine of codeunit 99000787 "Create Prod. Order Lines" we need an event:
[IntegrationEvent(false, false)]
local procedure OnCreateProdOrderLineOnBeforeInitProdOrderLine2(var Ishandled: Boolean; var ErrorOccured: Boolean; ProdOrder: Record "Production Order")
begin
end;
Changes between **:
local procedure CreateProdOrderLine(ProdOrder: Record "Production Order"; VariantCode: Code[10]; var ErrorOccured: Boolean)
var
SalesHeader: Record "Sales Header";
**IsHandled: Boolean;**
begin
DeleteLinesForProductionOrder(ProdOrder);
NextProdOrderLineNo := 10000;
InsertNew := false;
case ProdOrder."Source Type" of
ProdOrder."Source Type"::Item:
begin
OnCreateProdOrderLineOnBeforeInitProdOrderLine(InsertNew);
**Ishandled := false;
OnCreateProdOrderLineOnBeforeInitProdOrderLine2(Ishandled, ErrorOccured, ProdOrder);
if not Ishandled then begin**
InitProdOrderLine(ProdOrder."Source No.", VariantCode, ProdOrder."Location Code");
ProdOrderLine.Description := ProdOrder.Description;
ProdOrderLine."Description 2" := ProdOrder."Description 2";
ProdOrderLine.Validate(Quantity, ProdOrder.Quantity);
ProdOrderLine.UpdateDatetime();
if SalesLineIsSet then
CopyDimFromSalesLine(SalesLine, ProdOrderLine);
OnBeforeProdOrderLineInsert(ProdOrderLine, ProdOrder, SalesLineIsSet, SalesLine);
ProdOrderLine.Insert();
if ProdOrderLine.HasErrorOccured() then
ErrorOccured := true;
**end;**
OnAfterProdOrderLineInsert(ProdOrder, ProdOrderLine, NextProdOrderLineNo);
end;
ProdOrder."Source Type"::Family:
if not CopyFromFamily() then
ErrorOccured := true;
ProdOrder."Source Type"::"Sales Header":
begin
InsertNew := true;
if ProdOrder.Status <> ProdOrder.Status::Simulated then
SalesHeader.Get(SalesHeader."Document Type"::Order, ProdOrder."Source No.")
else
SalesHeader.Get(SalesHeader."Document Type"::Quote, ProdOrder."Source No.");
if not CopyFromSalesOrder(SalesHeader) then
ErrorOccured := true;
end;
end;
OnAfterCreateProdOrderLine(ProdOrder, VariantCode, ErrorOccured);
end;
Why do you need this change?
We need an event in CreateProdOrderLine procedure in order to manage the Item case with custom code.
In particular, we need to be able to assign a value to the parameter ErrorOccured, according to custom logics.
The OnCreateProdOrderLineOnBeforeInitProdOrderLine event is not sufficient for my scenario, since I don't have ErrorOccured as parameter to handle, moreover it is not possible to skip the code below using this event. So the ProdOrderLine record wouyld be initializate twice if I cannot skip it.
So the IsHandled parameter management is necessary.
The OnAfterProdOrderLineInsert event is not sufficient for my scenario, since I don't have ErrorOccured as parameter to handle.
Describe the request
In procedure CreateProdOrderLine of codeunit 99000787 "Create Prod. Order Lines" we need an event:
Changes between **: