File object not being cleared

Alex_Chow
Member Posts: 5,063
Hi Guys,
I'm running into a problem that I'm scratching my head over. Any help would be appreciated.
I have a process running using the OnTimer trigger in version 4.0SP1. The problem is that the file variable does not get cleared and seems to "capture" the contents of a directory at a point when the client is being ran. So new files are not being processed and the loop is always looping through the files already processed.
The question is, how do I clear the file variable so it gets the current contents of that folder?
Here's the code:
I'm running into a problem that I'm scratching my head over. Any help would be appreciated.
I have a process running using the OnTimer trigger in version 4.0SP1. The problem is that the file variable does not get cleared and seems to "capture" the contents of a directory at a point when the client is being ran. So new files are not being processed and the loop is always looping through the files already processed.
The question is, how do I clear the file variable so it gets the current contents of that folder?
Here's the code:
FileObject.RESET; CLEAR(FileObject); FileObject.SETFILTER(Path,'%1',TempPath); FileObject.SETFILTER(Name,'ORDER-*'); FileObject.SETRANGE("Is a file",TRUE); IF FileObject.FIND('-') THEN REPEAT TargetFilea := FileObject.Path + FileObject.Name; IF FILE.EXISTS(TargetFilea) THEN BEGIN <Runs a dataport pointing to TargetFilea> <Move the processed file into a separate folder> END; UNTIL FileObject.NEXT = 0;
Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
0
Answers
-
this is a known bug and discussed many times on mibuso. You need to set another filter and then nav will look at the folder again.0
-
ara3n wrote:this is a known bug and discussed many times on mibuso. You need to set another filter and then nav will look at the folder again.
Really? I searched and searched but couldn't find any thread on this.
When you said set another filter, can you elaborate? Do you mean change up the filter everytime the process is ran?Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0 -
ara3n is right. I've seen quite a lot of posts about this before. basically you need to change the filter 'path' before you do FIND. This is needed to refresh the folder.Microsoft Certified IT Professional for Microsoft Dynamics NAV
Just a happy frood who knows where his towel is0 -
FileObject.reset; FileObject.SETFILTER(Path,'%1','c:\'); FileObject.SETRANGE("Is a file",TRUE); IF FileObject.FIND('-') THEN; FileObject.reset; FileObject.SETFILTER(Path,'%1',TempPath); FileObject.SETFILTER(Name,'ORDER-*'); FileObject.SETRANGE("Is a file",TRUE); IF FileObject.FIND('-') THEN .....
0 -
Thank you!!!Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book0
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