Tuesday, November 25, 2008

Browse For Folder in Navision

Navisions implementation of Common Dialog Box does not cater to Browse for folder. There is a small workaround for this although it is not very neat but it does the work. Below is the code for the same this is a function which returns the FolderName and DefaultFolderName is the parameter to the function.


IF DefaultFolderName = '' THEN
DefaultFolderName := 'C:\Folder'
ELSE
DefaultFolderName := DefaultFolderName + '\Folder';

FolderName := CmmDlg.OpenFile('Select Folder'
, DefaultFolderName
, 4
, 'All File (*.*)|*.*'
, 0 );

//Truncate the file name from the path
Ctr :=STRLEN(FolderName);
WHILE Ctr > 0 DO BEGIN
IF COPYSTR(FolderName, Ctr, 1) = '\' THEN BEGIN
FolderName := COPYSTR(FolderName, 1, Ctr -1 );
EXIT;
END;
Ctr -= 1;
END

The only thing we are doing here is that we are providing a default filename in the browse window thus the open button is enabled without waiting for the user to select a file name.

4 comments:

NAVCRAZY said...

Hey Santosh, I have been struggling to make a directory browser in NAV, and I think this is a brilliant idea. Thanks for sharing it.

Chris Cherwin said...

Thanks, Santosh, for the directory browser solution. Works great.

Anonymous said...

Нey thеге, You have done an incredible job.
I will defіnitely ԁigg it and pеrsonally ѕuggest
to my frіеndѕ. I am confіdent they will
be benefited from this websitе.

my wеblog: http://pointsforfree.wordpress.com

Cindy Dy said...


I will keep your new article. I really enjoyed reading this post, thanks for sharing.

Sol
www.gofastek.com