microsoft / ALAppExtensions

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

[Event Request] Add the event OnBeforeCreateCreditMemoOnAction in page "Posted Purchase Invoices" in action "Create Credit Memo" #26714

Closed diogoviegas2855 closed 3 months ago

diogoviegas2855 commented 3 months ago

Describe the request

Hi Can you please add the event OnBeforeCreateCreditMemoOnAction in page "Posted Purchase Invoices" similar to the already existing one in "Posted Sales Invoices"

Actual Code:

action(CreateCreditMemo)
{
    ApplicationArea = Basic, Suite;
    Caption = 'Create Corrective Credit Memo';
    Image = CreateCreditMemo;
    Scope = Repeater;
    ToolTip = 'Create a credit memo for this posted invoice that you complete and post manually to reverse the posted invoice.';

    trigger OnAction()
    var
        PurchaseHeader: Record "Purchase Header";
        CorrectPostedPurchInvoice: Codeunit "Correct Posted Purch. Invoice";
    begin
        if CorrectPostedPurchInvoice.CreateCreditMemoCopyDocument(Rec, PurchaseHeader) then
            PAGE.Run(PAGE::"Purchase Credit Memo", PurchaseHeader);
    end;
}

Suggestion Code:

action(CreateCreditMemo)
{
    ApplicationArea = Basic, Suite;
    Caption = 'Create Corrective Credit Memo';
    Image = CreateCreditMemo;
   Scope = Repeater;
    ToolTip = 'Create a credit memo for this posted invoice that you complete and post manually to reverse the posted invoice.';

    trigger OnAction()
    var
        PurchaseHeader: Record "Purchase Header";
        CorrectPostedPurchInvoice: Codeunit "Correct Posted Purch. Invoice";
        IsHandled: Boolean;
    begin
        IsHandled := false;
        OnBeforeCreateCreditMemoOnAction(Rec, IsHandled);
        if IsHandled then
            exit;

        if CorrectPostedPurchInvoice.CreateCreditMemoCopyDocument(Rec, PurchaseHeader) then begin
            PAGE.Run(PAGE::"Purchase Credit Memo", PurchaseHeader);
            CurrPage.Close();
        end;
    end;
}

[IntegrationEvent(false, false)]
    local procedure OnBeforeCreateCreditMemoOnAction(var PurchInvHeader: Record "Purch. Inv. Header"; var IsHandled: Boolean)
begin
end;

Additional context

I need this event in order to control if i would like to create the standard credit memo or a customized one. Internal work item: AB#539243

JesperSchulz commented 3 months 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: 21464.