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
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...
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.
...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.
this is how i solve this kind of "errors":
RRCheckEmpty.GETTABLE(TBItemTemp);
IF NOT RRCheckEmpty.ISTEMPORARY THEN
ERROR('TBItemTemp variable must be temporary!!!');
TBItemTemp.DELETEALL;
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso My Blog
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.
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.
why not...the problem is that it's a bit of pain to declare recordref variables and error texts everytime...i thought about a way to do it in a codeunit, but we have the same old problem that we cannot pass a general table to a function
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso My Blog
Comments
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
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...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog
Great stuff. =D> Maybe add to the Tips and Tricks section if it is not already there.
My Blog - nav.education
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog