One of the functions I always missed in the old Common Dialog management was the "BrowseForFolder" dialog. Since I think NAV4.0 I used the function below (using the "Microsoft Shell Controls and Automation").
But well, now we've got NAV2013 and the "Commondialog Mgt." Codeunit was gone! (And so is my old function)
Fortunately we now got the "File Management" codeunit with all those file functions upgraded to RTC. With just a little programming this was my first attempt to recreate the function.
The OpenFolderDialog is a "System.Windows.Forms.FolderBrowserDialog" dotNet variable, aswell is the DialogResult variable (this one I copied from one of the other functions in the codeunit).
Just a piece of clean code, nothing special. Later on, I even found a blog post that reveals even more neat functions.
Next step was to test my function, but then I ran into the following error:
This message is for C/AL programmers: A call to System.Windows.Forms.FolderBrowserDialog.ShowDialog failed with this message: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
While looking into what caused the problem I suddenly realised that I forgot one crucial property to set in my variables.
After changing the RunOnClient property to "Yes" ("No" is the default), the error was solved!
When running dotNet components on the client side of your application, keep in mind to check this property!
Thanks for the post Marco, it was very useful