web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Creating an XML file or CSV file for Purchase Order using code and sending it to vendor's email address

(0) ShareShare
ReportReport
Posted on by 12

Hello All,

I have this requirement to fulfill where I have to create either csv file or xml of selected purchase order and that created file should be mailed to the e-mail of vendor presented in that purchase order.I have already created an action in purchase order called "Send Order to Vendor" but how can i write a code to create either csv file or xml file.

Any help will be appreciated

Thanks In Advance

*This post is locked for comments

I have the same question (0)
  • Tina Menezes Profile Picture
    2,582 on at

    Hi,

    You have to code in this way to create an csv or xml file.

      FileName:=FileManagement.ServerTempFileName('csv');

      PurchaseHeaderTable.RESET;

      PurchaseHeaderTable.SETRANGE("No.",PONumber);

      IF PurchaseHeaderTable.FINDFIRST THEN BEGIN

           REPORT.SAVEASEXCEL(405,FileName,PurchaseHeaderTable);

      END;

    Here FileManagement is a variable of type codeunit FileManagement and FileName is a variable of Text

    For attaching in xml format

    REPORT.SAVEASXML(405,FileName,PurchaseHeaderTable);

  • Sulav Thapaliya Profile Picture
    12 on at

    Thanks a lot Tina

    I will try this..

  • Suggested answer
    Marcellus Profile Picture
    2,735 on at

    Hi Sulav,

    Take a look at these two articles on MSDN:

    Walkthrough: Exporting Data from Tables to XML Documents

    Walkthrough: Exporting Data from Tables to CSV Files

    The two articles will show you how to build your xml port and how to develop a codeunit to execute them

    If you have not used XML ports before you may want to look at this too: https://msdn.microsoft.com/en-us/library/dd338846(v=nav.90).aspx

     Saurav Dhyani posted a very good article about sending smtp emails from NAV on his blog: https://saurav-nav.blogspot.co.uk/2017/05/microsoft-dynamics-nav-2017-email-from.html

  • Tina Menezes Profile Picture
    2,582 on at

    Hi,

    In addition to my previous answer, if you want to also know the procedure to send email with your .csv or .xml file of selected PO as an attachment, you can refer the below link of Saurav Dhyani.

    https://saurav-nav.blogspot.in/2013/08/send-mail-with-attachment-from-navision.html

  • Suggested answer
    Amol Salvi Profile Picture
    18,698 on at

    You can use XMLPORT for exporting the data in required format

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans