NAV 2009 R2 Classic - Dataport filename question

Hi Folks -

I have a dataport that imports 6 simple fields into a staging table. Currently the dataport is being run manually and customer wants to automate this process. I have put the dataport in Job queue and In the Sales & receivable setup table I have created a field called Import Path which will have something like C:\Importstaging\

The challenge I have is the filename will not be same every time. The filename will be Importstaging. and will be put in C:\importstging folder.

My question is how do I read the filename in my dataport from C:\Importstaging\ folder without knowing the filename and when the dataport runs it picks the file from the folder.

Any…Any help is highly appreciated.


You can use file record var to retrieve all files from required path, and set dataport filename from that var, and then run dataport.import.

Once dataport has been run, you have to remove the file from that path (you can move the file to other path).

You start your process by reading the file names from the imporstaging folders.

When I import something which should run via a job queue (normally via XMLPorts), then I always have a table I call the ImportQueue. Here I store file names, date/time and status of the files I have imported. Especially handy when working with XMLPorts, where I store the file in a blob field, before actually running the XMLPort.

But this way I always have a “placeholder” for error handling. Something which is even more important when importing via job queue, than when importing manually.

Although DataPorts works a little different, then you would still start with the same “scan folder for files”.

When the file has been successfully imported, then it can get the status = imported. But in your case, you might also use it to check it all the way, from your staging table to the actual table, before it get status = completed. And the more complex the actual table is (i.e. sales headers and lines are complex), the more error handling you need.

Basically the same answer, just in less words. [emoticon:c4563cd7d5574777a71c318021cbbcc8]

I guess it depends on how the file flow is going to be. If the file has been read into a blob field, then I usually just delete it. If not, then I would always copy it to an archive folder, before deleting it from the “inbox” folder. Sometimes both.

Again other times I need to first download the file from an FTP server, store it in an archive folder and then import it to NAV.

I’m writing from a mobile phone, I have to write in “short mode” ;).

We only know a part of the problem, and I just answer to that part (how to import a file if we do not know its filename). Anyway I totally agree with you.

Thank you very much Ponç J. Llaneras and Erik for all your help. That worked.