How to selec a folder in WEBCLIENT in Navision.

kovaidonkovaidon Posts: 37Member
Hi all,

I case of RTC , we have function in Codeunit -419(File Management) "SelectFolderDialog", Which is useful and can be used to select folder.

But in case of WEBCLIENT, this SELCTFOLDERDIALOG is not working.is there is any alternative.?

Please experts expecting your valuable suggestion

Best Answer

  • ftorneroftornero Posts: 155
    Accepted Answer
    Hello @kovaidon,

    Looks like the DotNet Folder Dialog doesn't work, so I did a workaround borrowing some functions from the codeunit 419 of BC.
    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
          [email protected] : DotNet "'mscorlib'.System.IO.File";
          [email protected] : DotNet "'mscorlib'.System.IO.Directory";
          [email protected] : DotNet "'mscorlib'.System.IO.Path";
    
        PROCEDURE [email protected](VAR [email protected] : TEMPORARY Record 823;[email protected] : Text);
        BEGIN
          TempNameValueBuffer.RESET;
          TempNameValueBuffer.DELETEALL;
    
          GetServerDirectoryListInclSubDirsInner(TempNameValueBuffer,DirectoryPath);
        END;
    
        LOCAL PROCEDURE [email protected](VAR [email protected] : Record 823;[email protected] : Text);
        VAR
          [email protected] : DotNet "'mscorlib'.System.Array";
          [email protected] : Text;
          [email protected] : Integer;
          [email protected] : 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 [email protected]([email protected] : Text) : Boolean;
        BEGIN
          EXIT(ServerDirectoryHelper.Exists(DirectoryPath));
        END;
    
        PROCEDURE [email protected]([email protected] : Text) : Text;
        BEGIN
          EXIT(PathHelper.GetFileNameWithoutExtension(FilePath));
        END;
    
        BEGIN
        END.
      }
    }
    

    You can call the function like this:
    FolderMgt.GetServerDirectoryListInclSubDirs(Buffer, 'C:\NAV09R2(32794)');
    PAGE.RUN(823, Buffer);
    

    There FolderMgt and Buffer (temporary) are:
    Name	DataType	Subtype
    FolderMgt	Codeunit	Folder Mgt.	
    Buffer	Record	Name/Value Buffer	
    

    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.

Answers

  • kovaidonkovaidon Posts: 37Member
    Mr. ftornero! Could you please help me out in this?
  • ftorneroftornero Posts: 155Member
    Hello @kovaidon,

    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.
  • kovaidonkovaidon Posts: 37Member
    Hi sir,

    it is for Updating Setup -Path Selection in Web Client environment.

  • ftorneroftornero Posts: 155Member
    Well, the problem with the "SelectFolderDialog" function in the codeunit 419 is that uses the DotNet vars to run on Client, and in the Web client you can not use this vars, but you can use DotNet vars that run on Sever.

    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.

    yc8qxbsbwtbe.png

    Regards.
  • kovaidonkovaidon Posts: 37Member
    Hi sir,

    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?
  • ftorneroftornero Posts: 155Member
    You can use DotNET vars in the server.

    Could you tell what version of NAV are you using ?
  • BlackTigerBlackTiger Posts: 1,177Member
    The Question here - how you are going to use it? Server code can't access (web)client's file system anyway.
    "You can’t just ask customers what they want and then try to give that to them.
    By the time you get it built, they’ll want something new.” Steve Jobs
  • kovaidonkovaidon Posts: 37Member
    Hi,

    Iam using NAv2017 Version.



  • ftorneroftornero Posts: 155Member
    Hello @BlackTiger ,

    I previously said that the server have to have access to the folder (a shared one).

    To @kovaidon, I going to do some test
  • ftorneroftornero Posts: 155Member
    Well, this the error when calling the "SelectFolderDialog" on the server with the web client

    luxycp3qgpum.png


    I'm going to try other options and keep you posted.

    Regards.
  • kovaidonkovaidon Posts: 37Member
    Hi sir,

    Exactly same error.

    Looking forward for your valuble input .

  • BlackTigerBlackTiger Posts: 1,177Member
    ftornero wrote: »
    Hello @BlackTiger ,

    I previously said that the server have to have access to the folder (a shared one).

    To @kovaidon, I going to do some test

    Are you going to select server's(!) folder from a windows(!) form running from webclient? Are you serious?
    "You can’t just ask customers what they want and then try to give that to them.
    By the time you get it built, they’ll want something new.” Steve Jobs
  • ftorneroftornero Posts: 155Member
    Accepted Answer
    Hello @kovaidon,

    Looks like the DotNet Folder Dialog doesn't work, so I did a workaround borrowing some functions from the codeunit 419 of BC.
    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
          [email protected] : DotNet "'mscorlib'.System.IO.File";
          [email protected] : DotNet "'mscorlib'.System.IO.Directory";
          [email protected] : DotNet "'mscorlib'.System.IO.Path";
    
        PROCEDURE [email protected](VAR [email protected] : TEMPORARY Record 823;[email protected] : Text);
        BEGIN
          TempNameValueBuffer.RESET;
          TempNameValueBuffer.DELETEALL;
    
          GetServerDirectoryListInclSubDirsInner(TempNameValueBuffer,DirectoryPath);
        END;
    
        LOCAL PROCEDURE [email protected](VAR [email protected] : Record 823;[email protected] : Text);
        VAR
          [email protected] : DotNet "'mscorlib'.System.Array";
          [email protected] : Text;
          [email protected] : Integer;
          [email protected] : 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 [email protected]([email protected] : Text) : Boolean;
        BEGIN
          EXIT(ServerDirectoryHelper.Exists(DirectoryPath));
        END;
    
        PROCEDURE [email protected]([email protected] : Text) : Text;
        BEGIN
          EXIT(PathHelper.GetFileNameWithoutExtension(FilePath));
        END;
    
        BEGIN
        END.
      }
    }
    

    You can call the function like this:
    FolderMgt.GetServerDirectoryListInclSubDirs(Buffer, 'C:\NAV09R2(32794)');
    PAGE.RUN(823, Buffer);
    

    There FolderMgt and Buffer (temporary) are:
    Name	DataType	Subtype
    FolderMgt	Codeunit	Folder Mgt.	
    Buffer	Record	Name/Value Buffer	
    

    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.
  • kovaidonkovaidon Posts: 37Member
    edited 2018-10-16
    Sir Fernando,

    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!!!!
  • BlackTigerBlackTiger Posts: 1,177Member
    Have you tested your code in Web Client?
    "You can’t just ask customers what they want and then try to give that to them.
    By the time you get it built, they’ll want something new.” Steve Jobs
  • kovaidonkovaidon Posts: 37Member
    BlackTiger wrote: »
    Have you tested your code in Web Client?

    Yes. it works Sir!,
  • BlackTigerBlackTiger Posts: 1,177Member
    kovaidon wrote: »
    BlackTiger wrote: »
    Have you tested your code in Web Client?

    Yes. it works Sir!,

    Ah, of course it works. This is pure NAV without windows callbacks.
    "You can’t just ask customers what they want and then try to give that to them.
    By the time you get it built, they’ll want something new.” Steve Jobs
Sign In or Register to comment.