Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

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

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
Categories:
  • Suggested answer
    Govinda Kumar Profile Picture
    Govinda Kumar 2,197 Super User 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
    Mohana Yadav 50,454 Super User 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
    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
    Nitin Verma 20,991 Super User 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
    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
    Govinda Kumar 2,197 Super User 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

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,995 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,610 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans