Browsing for a folder
NAV provides us with a way to browse for a file right out-of-the-box, but it does not let us browse for a folder. This recipe will show you a work around using automation controls that should already be installed on your system.
How to do it...
Create a new codeunit from Object Designer.
Add the following global variables:
Name
Type
Subtype
Length
MSShell
Automation
'Microsoft Shell Controls And Automation'.Shell
Folder
Automation
'Microsoft Shell Controls And Automation'.Folder3
FilesInFolder
Automation
'Microsoft Shell Controls And Automation'.FolderItems3
CurrentFile
Automation
'Microsoft Shell Controls And Automation'.FolderItem2
SelectedFolder
Text
1024
Add the following code to the
OnRun
trigger:CREATE(MSShell, FALSE, TRUE); Folder := MSShell.BrowseForFolder(0, 'NAV Folder Browser', 0); FilesInFolder := Folder.Items(); CurrentFile := FilesInFolder.Item(); SelectedFolder := FORMAT(CurrentFile.Path); MESSAGE('Selected Folder: %1\Contains %2...