How to get the first record from the filtered varaiable?

pawanp
Member Posts: 90
IF ItemVendor.FIND('-') THEN REPEAT Items.SETFILTER(Items."No." ,ItemVendor."Item No."); ItemsTemp := Items; ItemsTemp.INSERT; UNTIL ItemVendor.NEXT = 0;
ItemsTemp := Items; always returns the first record from the table?? Please help
0
Comments
-
Try this:
IF ItemVendor.FIND('-') THEN REPEAT Items.GET(ItemVendor."Item No."); ItemsTemp := Items; ItemsTemp.INSERT; UNTIL ItemVendor.NEXT = 0;
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Of course, you set the filter, but never did any FINDFIRST, FIND('-')...
1) you are using SETFILTER but only with two parameters. It is Better to use SETRANGE in this situation (or if you want to use SETFITLER, than Items.SETFILTER(Items."No." ,'%1',ItemVendor."Item No.");)
2) because you know the primary key of the record, much, much better is to use GET (Items.GET(ItemVendor."Item No.")). You do not need to filter and you have what you need in your variable...
And as I see, Kriki was faster...0 -
Your ItemsTemp is most probably an Item rec variable set to temporary. I don't advise that kind of use in a team of rookie developers, because someone who is programming by trying is going to try to fix a problem removing temporary property from record, and since this is a temporary table you have a .deleteall somwhere in your code. Oops. Some other programmer might want to try to validate this and that from the table, that is also not what you want.0
-
SLF25 wrote:...try to fix a problem removing temporary property from record, and since this is a temporary table you have a .deleteall somwhere in your code. Oops.
RRCheckEmpty.GETTABLE(TBItemTemp); IF NOT RRCheckEmpty.ISTEMPORARY THEN ERROR('TBItemTemp variable must be temporary!!!'); TBItemTemp.DELETEALL;
0 -
Belias wrote:this is how i solve this kind of "errors":
Code: Select all
RRCheckEmpty.GETTABLE(TBItemTemp);
IF NOT RRCheckEmpty.ISTEMPORARY THEN
ERROR('TBItemTemp variable must be temporary!!!');
TBItemTemp.DELETEALL;
Great stuff. =D> Maybe add to the Tips and Tricks section if it is not already there.0 -
matttrax wrote:Belias wrote:this is how i solve this kind of "errors":
Code: Select all
RRCheckEmpty.GETTABLE(TBItemTemp);
IF NOT RRCheckEmpty.ISTEMPORARY THEN
ERROR('TBItemTemp variable must be temporary!!!');
TBItemTemp.DELETEALL;
Great stuff. =D> Maybe add to the Tips and Tricks section if it is not already there.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