web
You’re offline. This is a read only version of the page.
close
Skip to main content
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 587

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,300 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

  • Suggested answer
    Tamilarasu Arunachalam Profile Picture
    587 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
    Nitin Verma Profile Picture
    21,684 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
    587 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
    Mohana Yadav Profile Picture
    60,967 Super User 2025 Season 2 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
    Govinda Kumar Profile Picture
    2,300 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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,327

#2
Sumit Singh Profile Picture

Sumit Singh 2,734

#3
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 2,599

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans