Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Not Allow to post Invoice directly from Purchase Order

Posted on by 295

How can I set up to not allow to post Invoice directly from Purchase Order ?

pastedimage1678938307907v2.png

Or if there is no function to set up, which action should I modify in AL code ?

Thank you.

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,135 Super User 2024 Season 2 on at
    RE: Not Allow to post Invoice directly from Purchase Order

    yes, it is standard info.

  • Hoang Ng Profile Picture
    Hoang Ng 295 on at
    RE: Not Allow to post Invoice directly from Purchase Order

    Thanks Yadav,

    I am sorry for late response.

    I used your 1st code and It showed as expected.

    pastedimage1679477875255v1.png

    But there is a small confusing that when I clicked Cancel it showed the error:

    "Please enter "Yes" in Receive and/or Invoice and/or Ship"

    pastedimage1679477959228v2.png

    Do you know whether this error message impact anything or just only "info" ?

    Thanks

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,135 Super User 2024 Season 2 on at
    RE: Not Allow to post Invoice directly from Purchase Order

    You can do it multiple ways

    1st code will just show the Receive option

        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch.-Post (Yes/No)", 'OnBeforeSelectPostOrderOption', '', false, false)]
        local procedure OnBeforeSelectPostOrderOption(var PurchaseHeader: Record "Purchase Header"; DefaultOption: Integer; var Result: Boolean; var IsHandled: Boolean);
        var
            ReceiveInvoiceQst: Label '&Receive';
            Selection: Integer;
        begin
            IsHandled := true;
            Selection := StrMenu(ReceiveInvoiceQst, DefaultOption);
            if Selection = 0 then
                Result := false;
            PurchaseHeader.Receive := Selection in [1, 3];
            PurchaseHeader.Invoice := Selection in [2, 3];

            Result := true;
        end;
    pastedimage1678941670651v1.png

    2nd code will throw error if user selects Invoice or "Receive and Invoice"


        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Purch.-Post (Yes/No)", 'OnAfterConfirmPost', '', false, false)]
        local procedure OnAfterConfirmPost(var PurchaseHeader: Record "Purchase Header");
        var
            InvErr: Label 'Posting Invoice is not allowed from Purchase Order.';
        begin
            if PurchaseHeader.Invoice then
                Error(InvErr);
        end;
    pastedimage1678941687823v2.png
  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Not Allow to post Invoice directly from Purchase Order

    There are many thing to achieve your requirement, some are below.

    1. No to enter Qty. to Invoice field value

    2. Put the error if someone does for point no. 1

    3. Put an error on Point No. 1

    4. Disable the Invoice menu option by going to Codeunit 91

    5. Put your logic on OnBeforePosting, in codeunit 90

    Thanks.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans