A tricky problem with the File system table...

davoness
Member Posts: 22
I am having a problem with using the File record.
I have a report that is aiming to go through a certain folder and for each text file in that folder process it into Navision and archive it.
The report has one data item, of type File. This has the following Table View:
SORTING(Path,Is a file,Name) ORDER(Ascending) WHERE(Is a file=CONST(Yes))
OnPreDataItem I am setting a range on the folder based on a field on the Request form as follows
SETRANGE(Path,Filepath);
This works fine the first time it is run, however it is as if the values in the File table are cached - If the first run has archived all files out of the folder, on the second run it attempts to process the same files again. If I compile the report, the File variable seems to be 'refreshed' and it will correctly process nothing.
Also, if it is processed when there are no files in the source folder, and files are subsequently added, these are not picked up until I have compiled the report.
Is there a way to refresh the File table OnPreReport so that it provides an up-to date view? I have tried to RESET or CLEAR the variable, creating a second file variable and doing the same SETRANGE and then FIND('-') and FIND('+') and inserting a SLEEP(1) to give control back to the OS, none of which have worked. Any ideas would be appreciated.
Thanks
I have a report that is aiming to go through a certain folder and for each text file in that folder process it into Navision and archive it.
The report has one data item, of type File. This has the following Table View:
SORTING(Path,Is a file,Name) ORDER(Ascending) WHERE(Is a file=CONST(Yes))
OnPreDataItem I am setting a range on the folder based on a field on the Request form as follows
SETRANGE(Path,Filepath);
This works fine the first time it is run, however it is as if the values in the File table are cached - If the first run has archived all files out of the folder, on the second run it attempts to process the same files again. If I compile the report, the File variable seems to be 'refreshed' and it will correctly process nothing.
Also, if it is processed when there are no files in the source folder, and files are subsequently added, these are not picked up until I have compiled the report.
Is there a way to refresh the File table OnPreReport so that it provides an up-to date view? I have tried to RESET or CLEAR the variable, creating a second file variable and doing the same SETRANGE and then FIND('-') and FIND('+') and inserting a SLEEP(1) to give control back to the OS, none of which have worked. Any ideas would be appreciated.
Thanks
0
Comments
-
Hi
Don't know if this will work but try using SELECTLATESTVERSION
on InitReport0 -
I had same problem. But now, I am using local variables where possible, calling Clear() before using, and it is working...0
-
Thanks for the suggestion, unfortunately it didn't solve the problem, but I have found a solution.
Inserting the following OnPreReport fixed the problem.
CashReceiptFiles.SETRANGE(Path,ENVIRON('Temp'));
IF CashReceiptFiles.FIND('-') THEN;
If you set a range on a different directory it refreshes the list. ENVION('Temp') is all I could think of that would always exist (ie some citrix users may not have a c:\, but navision always has a temp folder)0 -
That is a very annoying issue, and you have the only way to make that work. You have to reset the filter, get the content of that folder, and then reset it back and get the content again. It seems like the File virtual table is only able to get snapshots of file content.0
-
Are you running the report directly from a menu? If you are, then try running it from another object (i.e. codeunit/report/form). I had the same problem running a piece of code using the FILE record. When I moved it to a report it ran without a problem.Mark van der Meij,
http://home.casema.nl/mvandermeij0 -
Try to setrange to other file path before setrange to your intended path
SETRANGE(Path, OtherPath);
SETRANGE(Path,Filepath);0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions