Hi All,
I've a requirement where I need to import the csv file into NAV using XMLPort.
But the issue is XMLPort repeats the entry n number of times.
For eg:
Data in CSV File is
Entry | DataValue1 | DataValue2
------+-------------+-------------
1 Hello 06/07/2018
2 hi 06/07/2018
Data Imported is
Entry | DataValue1 | DataValue2
------+-------------+-------------
1 Hello 06/07/2018
2 Hello 06/07/2018
Also, I'm try to the same by calling the XMLport through code. But how do I set the path for the CSV file to be imported. Kindly suggest.
*This post is locked for comments
Thanks for the sample code.
To set the file name, you can use MyXMLPort.FILENAME([NewFileName]).
Check also this sample that could be useful (direct reading of a file as input):
//VARIABLES:
Name DataType Subtype Length
SalesOrderXmlFile Text
XmlStream InStream
IsImported Boolean
ImportXmlFile File
FileMgmt Codeunit File Management
//CODE:
SalesOrderXmlFile := 'C:\Temp\SalesOrder.xml';
ImportXmlFile.OPEN(SalesOrderXmlFile);
ImportXmlFile.CREATEINSTREAM(XmlStream);
IsImported := XMLPORT.IMPORT(XMLPORT::"Sales Header", XmlStream);
IF (IsImported = TRUE) THEN
MESSAGE('The import from XML is complete.')
ELSE
MESSAGE(GETLASTERRORTEXT);
ImportXmlFile.CLOSE;
FileMgmt.MoveClientFile(SalesOrderXmlFile,'c:\temp\archive\salesorder.xml');
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156