XMLPORT(Export) save in a destination automatically

bassoumabassouma Member Posts: 12
edited 2014-07-17 in NAV Three Tier
Hello everyone,

I create an XMLPORT to export some information from navision 2013 R2, I want when i run the XMLPORT, it will saving automaticaly in a destination that it is alreadey setup.
How can i do this?
I write this in OnPreXmlPort:

currXMLport.FILENAME(InterfaceSetup."Export Contract Comete Folder" + FileName + '.csv');
But when i run i have the dialog box to save.
I would like that should saving automatically in this folder.

Comments

  • geordiegeordie Member Posts: 655
    You need to use an OutStream variable to export automatically the file generated by XmlPort, running the process it from a calling codeunit. For instance:
    IF EXISTS(XmlFileName) THEN
      ERASE(XmlFileName);
    
    XmlFile.CREATE(XmlFileName);
    XmlFile.CREATEOUTSTREAM(OutStreamVar);
    XMLPORT.EXPORT(XMLPORT::"Your XmlPort",OutStreamVar); 
    XmlFile.CLOSE;
    
  • bassoumabassouma Member Posts: 12
    When i create this file(.csv).
    If Exist(XmlFileName)
    I don't like to ECRASE it I would like to create another with a postfix variable.
    How can i do this ?
  • geordiegeordie Member Posts: 655
    Change the code in:
    XmlFileName := 'Outputfile';
    XmlFileNameExt := '.xml';
    
    IF EXISTS(XmlFileName + XmlFileNameExt) THEN
      XmlFileName += '_1'; 
    
    XmlFile.CREATE(XmlFileName + XmlFileNameExt);
    XmlFile.CREATEOUTSTREAM(OutStreamVar);
    XMLPORT.EXPORT(XMLPORT::"Your XmlPort",OutStreamVar); 
    XmlFile.CLOSE;
    

    In case insert the the file check in a repeat-until loop to find a proper suffix to use.
  • bassoumabassouma Member Posts: 12
    With This:
    IF EXISTS(XmlFileName + XmlFileNameExt) THEN
    XmlFileName += '_1';
    I will have all the time XmlFileName + '_1' but i want that the first time it 1, the second 2,3,4..
  • geordiegeordie Member Posts: 655
    REPEAT
      Suffix += 1;
      XmlFileName := 'Outputfile_' + Suffix + '.xml';
    UNTIL (NOT (EXISTS(XmlFileName)));
    
  • bassoumabassouma Member Posts: 12
    Thanks :)
  • maheshroyal34maheshroyal34 Member Posts: 19
    Hi geordie,

    Have some filters in XML port, but when i running it from codeunit able to export the file to a particular location but not able to set the filters in XML . is there any solution to set the filters of XML-Port when running form codeunit.
  • SuDSuD Member Posts: 102
    bassouma wrote: »
    Thanks :)

    Dont forget to marked answerd it.. :)
Sign In or Register to comment.