Well, the problem is, when I enter a filename, it is asking for an importfilename while I have set it as an export.
I get an error when you enter a filename which is not existing because it needs to be an export file.
I guess you have to change to header part and Ja/Nej to Yes/No or what your stx file expect - other than that it should be straightforward to reproduce. Tested in 3.60 and 4.00-Update1 with same result. The only solution I know is to use Common Dialog, either directly or via codeunit 412.
Edit: The above sample reproduce the problem directly in a dataport, but if you remove the code in OnOpenForm you will get the same result as the original post.
I know I don't update the filename, but it doesn't change anything. Didn't you notice that there is no Dataitem, so it doesn't import or export much? 8)
I think there are 2 problems here, but only one was answered.
1) It is pretty well explained how to simulate the Filename and Direction controls in order to have even more controls on the request form.
2) But this solution has a problem, which was expressed also by Roleof:
...the problem is, when I enter a filename, it is asking for an import filename while I have set it as an export. I get an error when you enter a filename which is not existing because it needs to be an export file.
The problem is that the "control simulation" is not perfect. Although the code OnValidate changes the setting of CurrDataport.IMPORT to Export, the Assist Edit on the filename behaves always the same way - that is opening a dialog Dataport Import File Name. Of course the very same dialog insists that the file should exist before, and therefore issuing an error, if you actually want to export to a new file.
The workaround is to additionally set the default Dataport property IMPORT to NO!
This way the dialog that opens for file selection will always be Dataport Export File Name. These is perfect when actually exporting, but when importing, the dialog will accept also un-existing filenames (which is not ok) but will at least close. Of course when hitting the OK button on the Dataport it will again check the file existence and issue an error if the filename actually doesn't exist.
Simple as that \:D/ So no Common Dialog programming or CU412.
BTW, it's been a while since I was around here, so greets to all.
I have a question regarding dynamically changing the 'IMPORT' option on a Dataport. When I use this like:
DataportName.IMPORT(FALSE);
DataportName.RUN;
it is not being set as an export. How can I dynamically change that?
Roelof de Jong.
Hi All,
It's stupidly ](*,) but for dynamically changing Import option necessary default <Yes> Import property of the dataport changed just to Yes or No and code will be work \:D/
I am getting an error:
"The operating system cannot find the drive and directory specified for the file Q:\BusinessServices\PDF_Invoices\CGB\Brazil\COMPANYNAME-03/06/13 17:02 .Please check that the drive, directory and file names are correct."
Why is it looking for a file to import?
Is there any way to force the file name for the Export in the way I need it?
Experience is what you get when you hoped to get money
1) the file name I would suggest adding a +'.txt' at the end.
2) did you try to simply the path to see if that works?
so instead of Q:\BusinessServices\PDF_Invoices\CGB\Brazil\
try c:\ (just to see if that works)
then q:\ then keep adding a directory to see where it fails.
Your generated filename is invalid. Do not use slashes nor colons.
In filenames, sometimes, Windows treats forward slashes like backslashes as folder separators. So, the error message probably is caused while trying to create the export file.
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I get an error when you enter a filename which is not existing because it needs to be an export file.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I have had the exact same problem and have reproduced it very simple: I guess you have to change to header part and Ja/Nej to Yes/No or what your stx file expect - other than that it should be straightforward to reproduce. Tested in 3.60 and 4.00-Update1 with same result. The only solution I know is to use Common Dialog, either directly or via codeunit 412.
Edit: The above sample reproduce the problem directly in a dataport, but if you remove the code in OnOpenForm you will get the same result as the original post.
Peter
EDIT: No that won;t help... that's to late.
Well, fortunately there is codeunit 412
I should not read mibuso this late, and with a beer!
You forgot to update the CurrReport.FILENAME
Just put this in your funtion....
I realy should get a social life
I HATE winter...
No Gardening
No Motorbiking
No Carpenting
No Noting
Just Internet 8)
Well, you are not the only one in this timezone, but I got the flu and no beer
Peter
Well! This works \:D/
And I'm drinking my 2nd beer now
Guess I should start drinking during working hours
Good luck surviving the flu!
I think there are 2 problems here, but only one was answered.
1) It is pretty well explained how to simulate the Filename and Direction controls in order to have even more controls on the request form.
2) But this solution has a problem, which was expressed also by Roleof:
The problem is that the "control simulation" is not perfect. Although the code OnValidate changes the setting of CurrDataport.IMPORT to Export, the Assist Edit on the filename behaves always the same way - that is opening a dialog Dataport Import File Name. Of course the very same dialog insists that the file should exist before, and therefore issuing an error, if you actually want to export to a new file.
The workaround is to additionally set the default Dataport property IMPORT to NO!
This way the dialog that opens for file selection will always be Dataport Export File Name. These is perfect when actually exporting, but when importing, the dialog will accept also un-existing filenames (which is not ok) but will at least close. Of course when hitting the OK button on the Dataport it will again check the file existence and issue an error if the filename actually doesn't exist.
Simple as that \:D/ So no Common Dialog programming or CU412.
BTW, it's been a while since I was around here, so greets to all.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
GREAT tip - this does exactly what I want!
I especially like the lack of any dialog programming!
-a
Hi All,
It's stupidly ](*,) but for dynamically changing Import option necessary default <Yes> Import property of the dataport changed just to Yes or No and code will be work \:D/
I need to export Table 18 from Navision 3.7.
Dataport - OnPreDataport()
CurrDataport.IMPORT(FALSE);
SRSetup.GET;
gvDateTime := CREATEDATETIME(TODAY, TIME);
gvFileName := SRSetup."Path for Data Export" + 'COMPANYNAME' + '-' + FORMAT(gvDateTime);
CurrDataport.FILENAME(gvFileName);
Properties:
Import = No
UseReqForm = No
I am getting an error:
"The operating system cannot find the drive and directory specified for the file Q:\BusinessServices\PDF_Invoices\CGB\Brazil\COMPANYNAME-03/06/13 17:02 .Please check that the drive, directory and file names are correct."
Why is it looking for a file to import?
Is there any way to force the file name for the Export in the way I need it?
2 things.
1) the file name I would suggest adding a +'.txt' at the end.
2) did you try to simply the path to see if that works?
so instead of Q:\BusinessServices\PDF_Invoices\CGB\Brazil\
try c:\ (just to see if that works)
then q:\ then keep adding a directory to see where it fails.
http://www.BiloBeauty.com
http://www.autismspeaks.org
In filenames, sometimes, Windows treats forward slashes like backslashes as folder separators. So, the error message probably is caused while trying to create the export file.
Result!
Thanks to both of you for the help and good advice.
Abc Co Ltd040613 0952.txt
Final code:
Dataport - OnPreDataport()
CurrDataport.IMPORT(FALSE);
SRSetup.GET;
gvDateTime := CREATEDATETIME(TODAY, TIME);
gvDateTimeText := FORMAT(gvDateTime);
gvDateTimeText := DELCHR(gvDateTimeText,'=',':'); /// remove colons
gvDateTimeText := DELCHR(gvDateTimeText,'=','/'); /// remove forward slashes
gvFileName := SRSetup."Path for Data Export" + COMPANYNAME + gvDateTimeText + '.txt';
CurrDataport.FILENAME(gvFileName);
The path was not the problem but I did try first with c:\ then went for it.