microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
748 stars 600 forks source link

[Event request] Codeunit 1002 "Job Create-Invoice" - procedure DeleteSalesLine #26760

Closed mrabus closed 5 days ago

mrabus commented 1 week ago

Describe the request

I need to execute some business logic based on the JobPlanningLineInvoice record before it is delete, therefor I propose the following extensibility event:

procedure DeleteSalesLine(SalesLine: Record "Sales Line")
    var
        JobPlanningLineInvoice: Record "Job Planning Line Invoice";
        JobPlanningLine: Record "Job Planning Line";
        IsHandled: Boolean;
    begin
        IsHandled := false;
        OnBeforeDeleteSalesLine(SalesLine, IsHandled);
        if IsHandled then
            exit;

        case SalesLine."Document Type" of
            SalesLine."Document Type"::Invoice:
                JobPlanningLineInvoice.SetRange("Document Type", JobPlanningLineInvoice."Document Type"::Invoice);
            SalesLine."Document Type"::"Credit Memo":
                JobPlanningLineInvoice.SetRange("Document Type", JobPlanningLineInvoice."Document Type"::"Credit Memo");
        end;
        JobPlanningLineInvoice.SetRange("Document No.", SalesLine."Document No.");
        JobPlanningLineInvoice.SetRange("Line No.", SalesLine."Line No.");
        if JobPlanningLineInvoice.FindSet() then
            repeat
            //NEW CODE
            OnDeleteSalesLineOnBeforeGetJobPlanningLine(JobPlanningLineInvoice);
            //NEW CODE 
                JobPlanningLine.Get(JobPlanningLineInvoice."Job No.", JobPlanningLineInvoice."Job Task No.", JobPlanningLineInvoice."Job Planning Line No.");
                JobPlanningLineInvoice.Delete();
                JobPlanningLine.UpdateQtyToTransfer();
                OnDeleteSalesLineOnBeforeJobPlanningLineModify(JobPlanningLine);
                JobPlanningLine.Modify();
            until JobPlanningLineInvoice.Next() = 0;
    end;

 //NEW CODE 
  [IntegrationEvent(false, false)]
  local procedure OnDeleteSalesLineOnBeforeGetJobPlanningLine(JobPlanningLineInvoice: Record "Job Planning Line Invoice")
  begin
  end;

Additional context

This change allows to trigger logic based on the JobPlanningLineInvoice before it is deleted Internal work item: AB#539833

JesperSchulz commented 5 days ago

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

Build ID: 21487.