One of the essential requirement usually requested by user is to one time setup of File path and File name for Exporting/Importing various types of data. Similarly I did this for one of my user who wants single time setup of exporting data to particular location.
In following sections I will show how to add FilePath EDT on table with Directory browser on the form.
1) ADD/DROP the FilePath and FileName EDT's on your setup table , I have used EcoResProductParameter in my case :
Drag and Drop FilePath EDT on table fields as shown below :
Drag and Drop FileName EDT on table fields as shown below :
2) After adding FilePath and FileName fields on table , find your setup form and drop the newly added fields from Form datasource to Form design. See the snapshot below :
Drag and drop FilePath and FileName Field from Form datasource to design :
After Adding the fields on form, make the AutoDeclaration property of FilePath field only to yes.
You can open the form from AX and see the directory open icon along with field :
The problem here is that it would not open directory browser by clicking the file browser icon so only adding FilePath EDT would not work, you will need to add the following methods to your form methods node :
str fileNameLookupFilename()
{
Filename filepath;
Filename filename;
Filename fileType;
{
Filename filepath;
Filename filename;
Filename fileType;
[filepath, filename, fileType] = fileNameSplit(KwdUPCNullFilePath.text()); //KwdUPCNullFilePath is the FilePath field control name
return filename + fileType;
}
}
container fileNameLookupFilter()
{
#File
Filename filepath;
Filename filename;
Filename fileExtention;
{
#File
Filename filepath;
Filename filename;
Filename fileExtention;
[filepath, filename, fileExtention] = Global::fileNameSplit(KwdUPCNullFilePath.text()); //KwdUPCNullFilePath is the File Path field control name
if (!fileExtention)
{
fileExtention = #txt;
}
{
fileExtention = #txt;
}
return [WinAPI::fileType(fileExtention),#AllFilesName+fileExtention, #AllFilesExt, #AllFilesType];
}
}
str filenameLookupInitialPath()
{
return "";
}
}
str filePathLookupTitle()
{
return "Select Directory";
}
{
return "Select Directory";
}
str fileNameLookupTitle()
{
return "Select a folder for export";
}
{
return "Select a folder for export";
}
Now Try opening form again and click on directory browser icon it will open the new window to browse directory.




No comments:
Post a Comment