Skip to main content

Notifications

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 558

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
  • Suggested answer
    Govinda Kumar Profile Picture
    2,211 Moderator on at
    RE: Post the Sales Invoice through Power Automate by calling the action in the flow

    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.

  • Suggested answer
    Mohana Yadav Profile Picture
    60,213 Super User 2025 Season 1 on at
    RE: Post the Sales Invoice through Power Automate by calling the action in the flow

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

  • Suggested answer
    Tamilarasu Arunachalam Profile Picture
    558 on at
    RE: Post the Sales Invoice through Power Automate by calling the action in the flow

    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
    Nitin Verma Profile Picture
    21,544 Moderator on at
    RE: Post the Sales Invoice through Power Automate by calling the action in the flow

    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
    558 on at
    RE: Post the Sales Invoice through Power Automate by calling the action in the flow

    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
    Govinda Kumar Profile Picture
    2,211 Moderator on at
    RE: Post the Sales Invoice through Power Automate by calling the action in the flow

    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

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,206 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,968 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans