Options

Please help....how can I get a XML default file location?

boywonderboywonder Member Posts: 179
I'm trying to get an XMLport to open a given folder and filetype.

No problem on the filetype, I simply changed the FileName property in the XMLport to CC*.csv which shows only the files I'm interested in.

But can't figure out a way to do the filename, I tried the old tricks that were used for Dataports but they didn't work.

Help! :?

Comments

  • Options
    Alex_ChowAlex_Chow Member Posts: 5,063
    Did you try putting similar code to the OnInitXMLPort trigger:

    TempFileName := currXMLport.FILENAME(pathname);
  • Options
    boywonderboywonder Member Posts: 179
    Yes I did and it kind of works - but only puts the "path text" into the filename box when the Open File dialog box opens - doesn't actually change to the folder unless you hit <Return>....and of course they aren't going to want to have to do that.

    Maybe it just isn't possible with XMLports to do any better than that though? :?
  • Options
    Alex_ChowAlex_Chow Member Posts: 5,063
    Yeah, it's really stupid.

    In addition, the XMLport won't function like a dataport if you schedule it using NAS. :(

    In another words, you cannot automate XMLport to have it import .csv files..
  • Options
    mgmmgm Member Posts: 126
    This might do the trick!?

    Create a Function with the following code. I call it from an Action, but it should work when called from the NAS. Shouldn't it?
    // Import File
    FileRec.SETRANGE("Is a file",TRUE);
    FileRec.SETFILTER(Path,GLSetup."File Location Import");
    IF FileRec.ISEMPTY THEN
      ERROR(Text50010,GLSetup.FIELDCAPTION("File Location Import"));
    FileRec.FINDSET;
    REPEAT
      FromFileName := FileRec.Path + '\' + FileRec.Name;
      IF ISSERVICETIER THEN
        FromFileName := RBAutoMgt.UploadFile(FromFileName);
      ImportFile.OPEN(FromFileName);
      ImportFile.CREATEINSTREAM(InStream);
      IF XMLPORT.IMPORT(XMLPORT::"Import CSV File",InStream) THEN;
      ImportFile.CLOSE;
    UNTIL FileRec.NEXT = 0;
    


    In Codeunit 419 add this function
    UploadFile(ClientFileName : Text[1024]) : Text[1024]
    FileInfo := FileInfo.FileInfo(ClientFileName);
    ClientTempFileName(FileInfo.Name,FileInfo.Extension); // RTC Temp Folder (=Client)
    IF FileInfo.DirectoryName <> ClientTempPath THEN // Copy File on Client to Client Temp Folder
      FileInfo.CopyTo(ClientTempPath + FileInfo.Name,TRUE);
    
    UPLOAD('',Magicpath,'',FileInfo.Name,ServerFileName); // Upload Client File to Server
    
    IF ERASE(ClientTempPath + FileInfo.Name) THEN;
    
    EXIT(ServerFileName);
    
Sign In or Register to comment.