'Find' code on Form acting erratically
Mauddib
Member Posts: 269
Hi guys,
I have a small problem that I will put in terms of the sales line table to help explain it. Picture The normal sales order form with header and lines. In the ONVALIDATE() trigger for "No." of the Sales Line FORM I have the following code. I have also tried it on the sales line TABLE onvalidate() for "No." with the same problem:
//Ensure item isnt already on order. IF it is JUMP To the existing item.
LRecSoLine.RESET; //LRecSoLine - Record of sales line table.
LRecSoLine.SETCURRENTKEY("Document No.", "No.");
LRecSoLine.SETRANGE("Document No.", "Document No.");
LRecSoLine.SETRANGE("No.", "No.");
LRecSoLine.SETFILTER("Line No.", '<>%1', Rec."Line No.");
IF (LRecSoLine.FIND('-')) THEN BEGIN
Rec := LRecSoLine;
Rec.FIND;
EXIT;
END ELSE BEGIN
IF INSERT THEN;
END;
Now picture an order of 10 lines all with different items. You go to the END of this list to insert a new line and you enter an existing item and it jumps to the line containing the existing item. Wonderful!!!
However... if you go into the middle of the 10 lines and hit F3 to insert a line then do the same thing it does NOT jump to the existing Item's line.
Thoughts??? I have Currform.UPDATE(FALSE) in the onaftervalidate() too.
I have a small problem that I will put in terms of the sales line table to help explain it. Picture The normal sales order form with header and lines. In the ONVALIDATE() trigger for "No." of the Sales Line FORM I have the following code. I have also tried it on the sales line TABLE onvalidate() for "No." with the same problem:
//Ensure item isnt already on order. IF it is JUMP To the existing item.
LRecSoLine.RESET; //LRecSoLine - Record of sales line table.
LRecSoLine.SETCURRENTKEY("Document No.", "No.");
LRecSoLine.SETRANGE("Document No.", "Document No.");
LRecSoLine.SETRANGE("No.", "No.");
LRecSoLine.SETFILTER("Line No.", '<>%1', Rec."Line No.");
IF (LRecSoLine.FIND('-')) THEN BEGIN
Rec := LRecSoLine;
Rec.FIND;
EXIT;
END ELSE BEGIN
IF INSERT THEN;
END;
Now picture an order of 10 lines all with different items. You go to the END of this list to insert a new line and you enter an existing item and it jumps to the line containing the existing item. Wonderful!!!
However... if you go into the middle of the 10 lines and hit F3 to insert a line then do the same thing it does NOT jump to the existing Item's line.
Thoughts??? I have Currform.UPDATE(FALSE) in the onaftervalidate() too.
0
Comments
-
One thing to take into consideration is to never write code like that on the form. This type of validation code belongs in the table. I would create a new form for order entry that does this type of thing, or have an entry area on the header part.0
-
Ok I put it on the form because for some reason I'd convinced myself it wouldnt work on the Table. I have put the same code on the table now but the same unusual behaviour is occurring.
As for creating a new form or using the header to do the work I am afraid due to the requirements of the project this is not an option.0 -
Some notes to your code:
1. You have to add "Document Type" filter
2. You have to add "Type" filter
3. Never use INSERT in this table explicitly
I hope it helps you0 -
And you are sure what you are doing cant be resolved simply by changing the key on the prints?0
-
Thanks lubost but I was just using the sales line table as an example because everyone understands this table. The problem happens on this table JUST like on my own table.
The table where I am ACTUALLY having the same problem doesnt have document type, type or any problems with INSERT.
However if I can find out why is it happening on the sales lines, i will also know why it is happening on my own table.0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
