web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Post the Sales Invoice through Power Automate by calling the action in the flow

(0) ShareShare
ReportReport
Posted on by 593

Hi Folks,

     I have been stuck with the posting of sales invoice using the power automate by calling the action as a request.

I have tried some AL code to call the default codeunit then expose it as API and use it in Power Automate. Here is the code i tried

    procedure postSalesInvoice(var actionContext: WebServiceActionContext)
    var
        SalesInvoiceRecord: Record "Sales Invoice Header";
    begin

        Codeunit.Run(Codeunit::"Sales-Post (Yes/No)", SalesInvoiceRecord);
    end;
The action is exposed in flow and it results in the below error
pastedimage1680198647283v1.png
Do i need to change anything in the code or any other approach to make it possible?
Any help on this would be appreciated
I have the same question (0)
  • Suggested answer
    Govinda Kumar Profile Picture
    2,304 Moderator on at

    Hi,

    It would be helpful if you show the screenshot of exposing it in API and using it in power automate.. and parameters you're passing in the procedure..

    Regards

  • Suggested answer
    Tamilarasu Arunachalam Profile Picture
    593 on at

    Hi Govinda Kumar,

    Here is the screenshot of the procedure i have created inside an api page named salesInvoices.

    pastedimage1680238465500v2.png

    I have used the above in power automate by the following step

    pastedimage1680238591417v3.png

  • Suggested answer
    Nitin Verma Profile Picture
    21,794 Moderator on at

    This codeunit you are using it will raised and confirm dialog, are you able to manage those dialog's options, like Ship, Invoice and Ship & Invoice?

    Thanks.

  • Suggested answer
    Tamilarasu Arunachalam Profile Picture
    593 on at

    Hi Nitin Verma ,

        Appreciate your help on this!

        As a newbie, I am not much familiar about handling those dialogs in Business Central

       Can you guide me with any reference or a sample snippet

  • Suggested answer
    Mohana Yadav Profile Picture
    61,206 Super User 2026 Season 1 on at

    Please use Sales-Post codeunit instead of Sales-Post (Yes/No)

  • Suggested answer
    Govinda Kumar Profile Picture
    2,304 Moderator on at

    Hi Tamilarasu Arunachalam 

    As Nitin Verma suggested earlier, you need to manage to hide the dialogs. To do this, I think you have to find the specific event in your code unit "Sales-Post (Yes/No)" which is responsible for showing dialog, I had a similar requirement a few days ago, and this is how I hid the dialog when posting General Entries.

        [EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post", 'OnBeforeCode', '', false, false)]
        local procedure OnBeforeCode(var GenJournalLine: Record "Gen. Journal Line"; var HideDialog: Boolean);
        var
            RoyaltyParameters: Record uerRoyaltyAllocationParameters;
        begin
            if RoyaltyParameters.Get() then begin
                if (RoyaltyParameters.uerShowPostInvoiceDialog = false) then begin
                    HideDialog := true;
                end;
                if (RoyaltyParameters.uerShowPostInvoiceDialog = true) then begin
                    HideDialog := false;
                end;
            end;
        end;

    Regards.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,937 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,031 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 700 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans