I need to skip the below highlighted function based on few condition. It is available in sales line OnDelete trigger. I did not find any integration event to skip this.
Is there any way to create a new OnDelete trigger and skip the base function.
trigger OnDelete()
var
SalesCommentLine: Record "Sales Comment Line";
CapableToPromise: Codeunit "Capable to Promise";
JobCreateInvoice: Codeunit "Job Create-Invoice";
IsHandled: Boolean;
begin
IsHandled := false;
OnDeleteOnBeforeTestStatusOpen(Rec, IsHandled);
if not IsHandled then
TestStatusOpen();
if (Quantity <> 0) and ItemExists("No.") then begin
ReserveSalesLine.DeleteLine(Rec);
CheckReservedQtyBase();
if "Shipment No." = '' then
TestField("Qty. Shipped Not Invoiced", 0);
if "Return Receipt No." = '' then
TestField("Return Qty. Rcd. Not Invd.", 0);
WhseValidateSourceLine.SalesLineDelete(Rec);
end;
if ("Document Type" = "Document Type"::Order) and (Quantity <> "Quantity Invoiced") then
TestField("Prepmt. Amt. Inv.", "Prepmt Amt Deducted");
CleanDropShipmentFields();
CleanSpecialOrderFieldsAndCheckAssocPurchOrder();
CatalogItemMgt.DelNonStockSales(Rec);
if "Document Type" = "Document Type"::"Blanket Order" then begin
SalesLine2.Reset();
SalesLine2.SetCurrentKey("Document Type", "Blanket Order No.", "Blanket Order Line No.");
SalesLine2.SetRange("Blanket Order No.", "Document No.");
SalesLine2.SetRange("Blanket Order Line No.", "Line No.");
if SalesLine2.FindFirst then
SalesLine2.TestField("Blanket Order Line No.", 0);
end;
if Type = Type::Item then begin
ATOLink.DeleteAsmFromSalesLine(Rec);
DeleteItemChargeAssignment("Document Type", "Document No.", "Line No.");
end;
if Type = Type::"Charge (Item)" then
DeleteChargeChargeAssgnt("Document Type", "Document No.", "Line No.");
if ("Document Type" = "Document Type"::Order) then
CapableToPromise.RemoveReqLines("Document No.", "Line No.", 0, false);
if "Line No." <> 0 then begin
SalesLine2.Reset();
SalesLine2.SetRange("Document Type", "Document Type");
SalesLine2.SetRange("Document No.", "Document No.");
SalesLine2.SetRange("Attached to Line No.", "Line No.");
SalesLine2.SetFilter("Line No.", '<>%1', "Line No.");
OnDeleteOnAfterSetSalesLineFilters(SalesLine2);
SalesLine2.DeleteAll(true);
end;
if "Job Contract Entry No." <> 0 then
JobCreateInvoice.DeleteSalesLine(Rec);
SalesCommentLine.SetRange("Document Type", "Document Type");
SalesCommentLine.SetRange("No.", "Document No.");
SalesCommentLine.SetRange("Document Line No.", "Line No.");
if not SalesCommentLine.IsEmpty then
SalesCommentLine.DeleteAll();
// In case we have roundings on VAT or Sales Tax, we should update some other line
if (Type <> Type::" ") and ("Line No." <> 0) and ("Attached to Line No." = 0) and ("Job Contract Entry No." = 0) and
(Quantity <> 0) and (Amount <> 0) and (Amount <> "Amount Including VAT") and not StatusCheckSuspended
then begin
Quantity := 0;
"Quantity (Base)" := 0;
"Qty. to Invoice" := 0;
"Qty. to Invoice (Base)" := 0;
"Line Discount Amount" := 0;
"Inv. Discount Amount" := 0;
"Inv. Disc. Amount to Invoice" := 0;
UpdateAmounts();
end;
if "Deferral Code" <> '' then
DeferralUtilities.DeferralCodeOnDelete(
"Deferral Document Type"::Sales.AsInteger(), '', '',
"Document Type".AsInteger(), "Document No.", "Line No.");
end;