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 :
Finance | Project Operations, Human Resources, ...
Suggested answer

Generate and export Sales invoice PDFs to Sharepoint folder

(3) ShareShare
ReportReport
Posted on by 514
Hello:
 
We're trying to integrate with a third-party bank to manage our customer payments. One of the requirement is to send the Sales order invoices in PDF format to our payment processor - most likely drop them into a SFTP site/folder. I'm thinking to tap into the invoice creation process to run the report generation programmatically when the invoice is created. The part that involves saving the PDF report to a destination (e.g., Sharepoint folder) which would ultimately allow me to push them to our SFTP server is my hang-up. Any recommendations on how to approach this problem? Can this all be done in X++ or will some C# be required? Thank you.
Categories:
I have the same question (0)
  • Suggested answer
    Sagar121 Profile Picture
    392 on at
    Generate and export Sales invoice PDFs to Sharepoint folder
    Hi, I would do this.

    Write X++ code to save the file in Azure Blob storage as this help to centeralized documents.

    Add an extra field in customer invoice jour table to track whether the file has been saved in Azure Blob.

    Create business event also for new invoice generation.

    Consume this business event in power automate or Azure Logic Apps. Based on the primary field information, fetch the file from Azure Blob storage.

    Note: Power Automate may not have a direct SFTP connector I am not fully sure, but Azure Logic Apps definitely supports it.

    You should consider all these scenario like

    If there are duplicate invoices, do not save the file in Blob and do not trigger the business event.

    If another version of the file is created,how will you handle also for error logging.

  • Sohaib Cheema Profile Picture
    47,788 User Group Leader on at
    Generate and export Sales invoice PDFs to Sharepoint folder
    Please correct me if I am wrong. You want one PDF for every invoice that is posted in the Dynamics, and you do not want the invoice file to be duplicated in your SFTP ?
  • CU29041349-0 Profile Picture
    514 on at
    Generate and export Sales invoice PDFs to Sharepoint folder
    I appreciate the overview of the process. The part I'm not understanding is if I'm hooked into the posting process, where would I save the PDF? It sounded like a 'local' location is available. Would you clarify this part, please? Thank you!
  • CU29041349-0 Profile Picture
    514 on at
    Generate and export Sales invoice PDFs to Sharepoint folder
    I would probably run the report generation as part of a batch job. I won't have a file location where I can drop the PDF. Would it be possible to specify a SFTP or Sharepoint location instead? Apologies for the late reply. Thanks!
  • CU29041349-0 Profile Picture
    514 on at
    Generate and export Sales invoice PDFs to Sharepoint folder
    Would you be able to provide some more details? As mentioned, I would like to eventually drop them into our SFTP folder, but maybe I can do that with Power Automate. 
    Thank you in advance, and apologies for the extremely late reply. 
  • Suggested answer
    DAnny3211 Profile Picture
    11,269 on at
    Generate and export Sales invoice PDFs to Sharepoint folder

    Hi CU39041349,

     

    Your goal of generating and exporting Sales invoice PDFs to a SharePoint folder (and eventually to an SFTP site) is achievable, and there are a few ways to approach it depending on your architecture and integration preferences.

     

    ✅ Recommended Approach

     

    1. Generate PDF Programmatically in X++

     

    You can hook into the invoice posting process and use X++ to:

     

    • Trigger the report generation (e.g., SalesInvoiceReport).

    • Use SrsReportRunController and SrsReportDataContract to generate the report.

    • Save the output as a PDF using File::SaveFile() or similar APIs.


    •  
     

    2. Export to SharePoint

     

    To push the PDF to SharePoint:

     

    • Use Power Automate to monitor a folder (e.g., Azure Blob or local file system) and upload files to SharePoint.

    • Alternatively, use C# with Microsoft Graph API to upload directly to SharePoint from within your integration layer.


    •  
     

    3. Forward to SFTP

     

    Once the file is in SharePoint or a staging folder:

     

    • Use PowerShell, Azure Logic Apps, or a custom C# service to push the file to your SFTP server.

    • You can also use third-party connectors or middleware like KingswaySoft or SSIS if needed.


    •  
     

    🛠️ Notes

     

    • While most of the logic can be handled in X++, file system and external service integration (SharePoint/SFTP) is best handled via C# or external services.

    • Ensure proper error handling and logging for file generation and transfer steps.

    • Consider security and access control when dealing with SharePoint and SFTP endpoints.


    •  
     

    Let me know if you'd like help drafting the X++ logic or setting up the Power Automate flow.

     

    Thanks and best regards,

    Daniele

    Note: This response was prepared with support from Copilot to ensure clarity and completeness.

  • Rahul T Profile Picture
    29 on at
    Generate and export Sales invoice PDFs to Sharepoint folder
    You can accomplish this using X++. To upload sales invoice PDFs to a SharePoint folder, you will need to register your application in Azure Active Directory with the appropriate permissions to access the SharePoint folder. Additionally, obtaining an OAuth access token is required for authorization to SharePoint.
     
     
  • Aditya Pal Profile Picture
    168 on at
    Generate and export Sales invoice PDFs to Sharepoint folder
    You can do with X++ 
    You can use the Print Management framework and SrsReportRunController to generate the invoice report as a PDF. A simplified example:
    public static void generateInvoicePdf(CustInvoiceJour _custInvoiceJour)
    {
        SrsReportRunController   controller = new SrsReportRunController();
        SRSPrintDestinationSettings settings = new SRSPrintDestinationSettings();
        Args args = new Args();
        args.record(_custInvoiceJour);
        controller.parmReportName(ssrsReportStr(SalesInvoice, Report));
        controller.parmArgs(args);
        // Configure PDF output
        settings.printMediumType(SRSPrintMediumType::File);
        settings.fileFormat(SRSReportFileFormat::PDF);
        settings.fileName(@"C:\Temp\Invoice_" + _custInvoiceJour.InvoiceId + ".pdf");
        controller.parmReportContract().parmPrintSettings(settings);
        controller.runReport();
    }
    This code will generate the invoice as a PDF and save it to a file location.
  • Sohaib Cheema Profile Picture
    47,788 User Group Leader on at
    Generate and export Sales invoice PDFs to Sharepoint folder
    You can do with X++ , You do not need to go to C# for document generation and saving it
    However you can also do without x++, standard system allows you to generate documents/reports and those being saved at SharePoint (site and folder of your choice).

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 756 User Group Leader

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 629 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 514 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans