Hi all,
This question has been asked before in a variety of flavors, but I haven't found this particular scenario with an answer.
We have a codeunit running in the NAV2016 job queue. The intent is to read a file on a network share, e.g.
\\servername\Scanfolder\sub\sub\thisfile.txt
It then parses that text file and puts some data in the NAV database.
The issue is that the server cannot find/read this file.
The userid that the service tier is running under has full Active Directory permissions to the \\servername\scanfolder. I can log into the server with this same userid and see the directory and open the file.
If I run the codeunit under the NAV client, this code fails:
FileName := '\\servername\data$\Scanned Documents\Logs\CD_NAV_Import.txt';
IF ScanFile.OPEN(FileName) THEN BEGIN
IF CONFIRM('Was able to open ' + FileName) THEN;
ScanFile.CLOSE;
END
ELSE
IF CONFIRM('Could not open file ' + FileName) THEN; <---Fails
EXIT;
If I use the File management codeunit functions, it works when running from a NAV client:
IF NOT FileMgt.ClientFileExists(FileName) THEN
EXIT;
TempFileName := FileMgt.UploadFileSilent(FileName);
IF ScanFile.OPEN(TempFileName) THEN ;
However, when running under a NAS session, the above code fails with this error:
Microsoft Dynamics NAV Server attempted to issue a client callback to create a DotNet object: System.IO.File (CodeUnit 419 File Management). Client callbacks are not supported on Microsoft Dynamics NAV Server.
Does anyone have working code that runs under a NAS sessions that reads data from a file on a network share? I don't mind having to copy it to a temp file if necessary, but I haven't found the right combination of methods to do this. I have also been told that the "delegation" method is not necessary for NAV2016 (that it applies only to 2009). I've also tried setting the delegation properties mentioned in other threads, but still no luck.
Thanks in advance,
Ron
Answers
If you have a dialog og message in you code, then it fails. NAS has no GUI
Thanks
Ron