OBJECT Codeunit 50997 Folder Mgt. { OBJECT-PROPERTIES { Date=15-10-18; Time=23:43:21; Modified=Yes; Version List=DIR; } PROPERTIES { OnRun=BEGIN END; } CODE { VAR ServerFileHelper@1000000003 : DotNet "'mscorlib'.System.IO.File"; ServerDirectoryHelper@1000000002 : DotNet "'mscorlib'.System.IO.Directory"; PathHelper@1000000004 : DotNet "'mscorlib'.System.IO.Path"; PROCEDURE GetServerDirectoryListInclSubDirs@1000000002(VAR TempNameValueBuffer@1000 : TEMPORARY Record 823;DirectoryPath@1001 : Text); BEGIN TempNameValueBuffer.RESET; TempNameValueBuffer.DELETEALL; GetServerDirectoryListInclSubDirsInner(TempNameValueBuffer,DirectoryPath); END; LOCAL PROCEDURE GetServerDirectoryListInclSubDirsInner@1000000001(VAR NameValueBuffer@1000 : Record 823;DirectoryPath@1001 : Text); VAR ArrayHelper@1002 : DotNet "'mscorlib'.System.Array"; FileSystemEntry@1004 : Text; Index@1003 : Integer; LastId@1005 : Integer; BEGIN ArrayHelper := ServerDirectoryHelper.GetDirectories(DirectoryPath); FOR Index := 1 TO ArrayHelper.GetLength(0) DO BEGIN IF NameValueBuffer.FINDLAST THEN LastId := NameValueBuffer.ID; EVALUATE(FileSystemEntry,ArrayHelper.GetValue(Index - 1)); IF ServerDirectoryExists(FileSystemEntry) THEN NameValueBuffer.ID := LastId + 1; NameValueBuffer.Name := COPYSTR(FileSystemEntry,1,250); NameValueBuffer.Value := COPYSTR(GetFileNameWithoutExtension(NameValueBuffer.Name),1,250); NameValueBuffer.INSERT; GetServerDirectoryListInclSubDirsInner(NameValueBuffer,FileSystemEntry) END; END; PROCEDURE ServerDirectoryExists@48(DirectoryPath@1000 : Text) : Boolean; BEGIN EXIT(ServerDirectoryHelper.Exists(DirectoryPath)); END; PROCEDURE GetFileNameWithoutExtension@35(FilePath@1000 : Text) : Text; BEGIN EXIT(PathHelper.GetFileNameWithoutExtension(FilePath)); END; BEGIN END. } }
FolderMgt.GetServerDirectoryListInclSubDirs(Buffer, 'C:\NAV09R2(32794)'); PAGE.RUN(823, Buffer);
Name DataType Subtype FolderMgt Codeunit Folder Mgt. Buffer Record Name/Value Buffer
Answers
Could you elaborate a little ?
- NAV version or it's BC
- on-premise
- cloud, etc.
And what do you want to achieve by selecting a folder ?
Regards.
it is for Updating Setup -Path Selection in Web Client environment.
So, if the folder to select is accesible form the server you can borrow that function ,copy to one of your codeunits and change the DotNet vars to run on Server.
Regards.
I have even tried with by setting Properties of RunOnClient- No(Which Run in Server). but it is not working, since the DOTNET Variable defined are Windows based .
Do we have option other than developing Java Script based Conteol addins for this?
Could you tell what version of NAV are you using ?
Iam using NAv2017 Version.
I previously said that the server have to have access to the folder (a shared one).
To @kovaidon, I going to do some test
I'm going to try other options and keep you posted.
Regards.
Exactly same error.
Looking forward for your valuble input .
Looks like the DotNet Folder Dialog doesn't work, so I did a workaround borrowing some functions from the codeunit 419 of BC.
You can call the function like this:
There FolderMgt and Buffer (temporary) are:
You need to provide a path to the function, an improve would be first show the logical units in the server an after choosing one show the folders.
Also you need to elaborate the call to the PAGE 823 to get the folder chosen.
Regards.
It works like Charms!. Please accept my Heartiest Thanks for your wonderful and Awesome Logic in bring out the output within limitations .
Once again Thank you very much ! Hatsoff to you Sir!!!!
Yes. it works Sir!,