I am trying to automate the code at the bottom of this message and I keep getting the errror bellow. I have made sure that the NAS user login has full permissions to the folders. The code does work from UI. Any help is apriciated.
Error: This message is for C/AL programmers: The call to member GetFolder failed. Unknown Class returned the following message: Unknown Error
Code:
IF ISCLEAR(FSO) THEN
CREATE(FSO);
Folder:=FSO.GetFolder('\\server\d$\lexicom\inbox\commercehub');
Files:=Folder.Files;
IF Files.Count>0 THEN BEGIN
FSO.CopyFile('\\svr2k1\d$\lexicom\inbox\commercehub\*', 'c:\navision\edi\combo');
FSO.MoveFile('\\svr2k1\d$\lexicom\inbox\commercehub\*', '\\server\d$\lexicom\inbox\commercehub\archive\');
END;
//Import Files
Import850;
Folder:=FSO.GetFolder('c:\navision\edi\c\outbox');
Files:=Folder.Files;
IF Files.Count>0 THEN BEGIN
FSO.CopyFile('c:\navision\edi\c\outbox\*','c:\navision\edi\c\outbox\archive\');
FSO.MoveFile('c:\navision\edi\c\outbox\*','\\server\d$\lexicom\outbox\commercehub\');
END;
Folder:=FSO.GetFolder('c:\navision\edi\kohls\outbox');
Files:=Folder.Files;
IF Files.Count>0 THEN BEGIN
FSO.CopyFile('c:\navision\edi\k\outbox\*','c:\navision\edi\k\outbox\archive\');
FSO.MoveFile('c:\navision\edi\k\outbox\*','\\server\d$\lexicom\outbox\commercehub\');
END;
CLEAR(FSO);
0
Comments
make sure that windows login for application server has permission for this operation. type services.msc in windows' run dialog and check user for navision application server service. permission is not related to nav user.
Folder:=FSO.GetFolder('c:\navision\edi\kohls\outbox');
Files:=Folder.Files;
IF Files.Count>0 THEN BEGIN
FSO.CopyFile('c:\navision\edi\k\outbox\*','c:\navision\edi\k\outbox\archive\');
FSO.MoveFile('c:\navision\edi\k\outbox\*','\\server\d$\lexicom\outbox\commercehub\');
END;
Error: An exception was raised in method GetFolder. The OLE control or Automation server has returned error (HRESULT) -2147352567.
The component did not provide the exception description.
When moving files, you can also use the build in standard NAV RENAME function:
[Ok :=] File.RENAME(OldName, NewName)