another blog


About Microsoft Dynamics GP :-)

How to find the names of all text file in a folder in Microsoft Dexterity.

In Microsoft Dexterity we have a function Path_SelectPathname to select folder path.

According to the manual description of the function:The Path_SelectPathname() function displays a file dialog box, allowing a user to indicate the location of a file, and returns a generic pathname to that location.

But there is no way in Sanscript that we can find the contents of the folder, like to list down any specific extension files, Although it’s a common need to read text files in dexterity, so if user needs to read multiple text files inside Dexterity then he needs to select each file by using getfile() function individually, that’s not a real life situation. SO the below is a work around where user will tell the folder path and system will read all the text files of the folder. Not coding a whole scenario, just the key part of reading files names from folder.

For this particular situation we will use VBScript and Batch file, my favorite command line commands. :)I am using Sanscript function Dict_GetPathname(PATH_DATAFOLDER) to create batch file there, also vbs file will be copied there, So this could be changed according to your choice of option for saving vbs and batch files. More details of the function will be read from Dexterity Manuals. In debug mood it means you have to copy your vbs file in the folder where your dictionary is.

Open a notepad and past following line, replace the path “E:\New Working\Almas gp2010\” with your Dictionary folder path and save as listfiles.vbs

Set objShell = WScript.CreateObject(“WScript.Shell”)
objShell.Run(“””E:\New Working\Almas gp2010\command.bat”””), 0, True

open your dexterity window and copy below code in folder path select button.This will create a text file having names of all the text files inside selected folder, which then can be read through TextFile_ReadLine() function with a while loop .There should be other checks added in code like if user not selects folder path then abort script  or etc, add them according to your needs. 🙂

local integer l_File_ID;
local string com,l_Path,l_listFile,b_path,path;
local boolean result;

result = Path_SelectPathname(l_Path);
if result = true then
    FilePath of window ies_selectfolder of form ies_selectfolder = Path_MakeNative(l_Path);
end if;
path=FilePath of window ies_selectfolder of form ies_selectfolder;
l_File_ID=TextFile_Open(b_path+”command.bat”, 0, 2);
TextFile_WriteLine(l_File_ID, “E:”);
TextFile_WriteLine(l_File_ID, “dir /s/b “””+path+”*.txt””>”+””””+b_path+”text.txt”+””””);
run application “”,b_path+”listfiles.vbs”;


Filed under: Dexterity Development, dynamics-gp, , , , , ,


Enter your email address to follow this blog and receive notifications of new posts by email.

Enter your email address to follow this blog and receive notifications of new posts by email.


Error: Twitter did not respond. Please wait a few minutes and refresh this page.

Blog Stats

  • 10,482 hits

RSS dynamics-gp

  • VSTools and database triggers.
    In SanScript coding we have database triggers, Below is a detail of what database triggers are as explained in dexterity manuals. Database triggers Database triggers are activated by successful table operations, such as a record begin read, saved, or deleted. The procedure that runs in response to a database trigger has access to the same […]
  • Getting the current active window in Dexterity.
    Using dexterity there is not a direct way of getting current active window information, but with set of available GP functions and triggers can make this task happen. Below I am sharing a trigger and function which can tell the active window name. Below code needs to be changed according to the needs of developer, […]
  • Hints and Tips… On going Post
    This is on going post and points will be added from time to time. 🙂 .. with Field Level Security we can not restrict document access on Sales transaction entry Window. Means we can not make user to choose only ‘Invoices’ in SOP Type drop down. .. we can not add custom table in table […]
  • Reversing the sort order of Receivable Transaction Inquiry – Customer by Document Date
    Last few months we got more request on changing sort orders of Inquiry windows and lookups and to cover them all in a one place I have been working on a small project which will provide a simple sorting without much effort. In Dynamics Community there was a post having similar situation, I have already […]
  • Getting the current open window in .net GP Add In
    There are many ways of getting information of active window in GP, but it changes according to the developing tool we are working on. 1.Dexterity.(the best tool 🙂
  • Not all RW_Function are meant for reports.
    There are lots of RW functions available in a report writer Calculated Field Definition window and almost all of them are so handy while working on report writer, but it is a matter of fact that some of them are not actually meant for report writer. Usually RW functions are associated with report writer and […]
  • Dexterity Can Wait and Respond.
  • Cross Dictionary Development.    
  • Calling Sales Document Numbers Lookup
    Often developers need to open available lookup on their custom form from dynamics GP.Sales Document Number lookup is a very common and much used lookup and every dynamics technical person needs to call it in once (or more) in their lifetime. 🙂 Dynamics GP SDK provide a prototype of coding on how to open various […]
  • This datatype name is already in use.
    This datatype name is already in use.
Ghostriver Studios Blog

Sculptural stained glass of Andrew Kosorok

Dynamics GP Builders & Reporting

How to use MS Dynamics SmartList Builder, Excel Report Builder and other Reporting tools to get the data and analysis you need.

%d bloggers like this: