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

Business Central - Action based flow to export the PO table when record is changed

(2) ShareShare
ReportReport
Posted on by 37
I can export the  PO table to Excel manually. I am trying to setup an "Action based flow" to export the PO table data (to an Excel SharePoint document) when a PO record is changed.
I am new to Flows and so I need pointing in the right direction!!!
 
I have added a "Trigger" called "When a record is modified"
 
What "Action" do i need to export the PO data? I can see there is one called "Excel online for business" but I can't see how to use this to export the data. Am I trying to use the wrong "Action"???
 
Thanks for your help
I have the same question (0)
  • Suggested answer
    Sohail Ahmed Profile Picture
    11,165 Super User 2026 Season 1 on at

    Yes, while Power Automate is one way to export PO data on record change, you can also do this directly in AL (Application Language) inside Business Central with full control over the logic.

     

    ✅ AL-based approach:

     

    You can write an event subscriber that triggers when a record in the Purchase Header table is modified, and then use AL code to export the data. Here's a high-level breakdown:

    🔹 Step 1: Create an Event Subscriber for OnModifyEvent of Purchase Header:

    [EventSubscriber(ObjectType::Table, Database::"Purchase Header", 'OnAfterModifyEvent', '', false, false)]
    local procedure OnAfterPOChanged(var Rec: Record "Purchase Header"; xRec: Record "Purchase Header")
    begin
        if Rec.Status = Rec.Status::Open then begin
            ExportPOToExcel(Rec);
        end;
    end;
    

    🔹 Step 2: Write the ExportPOToExcel function

    You can either:

    • Export the data to a CSV or Excel file using TempBlob, then upload to SharePoint.
    • OR, call an Azure Function or API to push the PO data directly.
     

    Example (simplified CSV approach):

     
     
    local procedure ExportPOToExcel(PurchaseHeader: Record "Purchase Header")
    var
    TempBlob: Codeunit "Temp Blob";
    OutStream: OutStream;
    FileContent: Text;
    begin
    FileContent := 'PO No,Vendor Name,Amount' + Format(13) + Format(10);
    FileContent += PurchaseHeader."No." + ',' + PurchaseHeader."Buy-from Vendor Name" + ',' + Format(PurchaseHeader.Amount);
    
    TempBlob.CreateOutStream(OutStream);
    OutStream.WriteText(FileContent);
    
    // Optionally send this file to SharePoint or store it somewhere
    end;
     
     

    To upload the file to SharePoint, you can integrate with Microsoft Graph API or use Power Automate triggered by an HTTP call from AL.

     
     

    🧠 Summary:

     
    • Yes, you can use AL to automatically export PO data on modification.
    • It gives you full control over data formatting, export logic, and integration.
    •  
    • If you’re comfortable in AL, this might be cleaner than managing Power Automate flows.
     
     

    Mark below checkbox to make this answer Verified if it helps you. ✅

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,091 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,032 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 946 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans