Why does my loop end after 1 iteration?

wolfulium
Member Posts: 30
SubJobsT.SETFILTER(SubJobsT."Master Job No.", JobsT."No."); IF SubJobsT.FINDSET THEN BEGIN REPEAT IF SubJobsT."Job Type" = Job."Job Type"::Resource THEN BEGIN // do stuff END ELSE BEGIN count := count + 1; NewJobNo := JobNoFormat(ResourceJobNo, count); NewJobNo := JobNoValidation(SubJobsT, NewJobNo); SubJobsT.LOCKTABLE; SubJobsT."Parent Job No." := parentJobNo; SubJobsT.MODIFY; SubJobsT.RENAME(NewJobNo); END; UNTIL SubJobsT.NEXT = 0; END; count := 0;
Here is a sample of the code, i cut things out that were not important.
However, I am trying to run this on a big set of jobs, and each master job has set of child jobs.
I have a group of jobs (96) that are all items (not resources) that run through this loop only one time.
It only does the first item of the list and then ends the loop.
Any suggestions?
0
Best Answer
-
Because you are renaming the record you are looping through. Use something like this:
if SubJobsT.findset then Repeat Subjobs2.init; Subjobs2 := SubJobsT; Subjobs2.rename(NewJobNo); until SubJobsT.next = 0;
5
Answers
-
Because you are renaming the record you are looping through. Use something like this:
if SubJobsT.findset then Repeat Subjobs2.init; Subjobs2 := SubJobsT; Subjobs2.rename(NewJobNo); until SubJobsT.next = 0;
5 -
I actually had that in there, but the loop would just run forever. The counts should be 0-96 but currently running at 256 and increasing. It seems that after you rename it, it is adding it back into the list and is run again0
-
Alright so i added a field called "isclean" and set it to true when the record was "renamed"
then checked to make sure the record's isclean field was false before continuing.
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