Customer.SETCURRENTKEY ("Credit Limit (LCY)"); Customer.SETFILTER ("Credit Limit (LCY)", '=0'); Customer.FIND ('-'); REPEAT Customer.CALCFIELDS (Balance); IF Customer.Balance <> 0 THEN Customer."Credit Limit (LCY)" := Customer.Balance ELSE Customer.”Credit Limit (LCY)" := 10000; Customer.modify; UNTIL Customer.NEXT = 0;
Comments
Jan Hoek
Product Developer
Mprise Products B.V.
Navision Solution Developer
Intelligent Systems Bulgaria
Where are the other posted message from Steve0?
To s.delikostov, thank you for your enlighments! Does it means the pointer always take the "unprocessed" first record?
Jemmy
When you modify Credit Limit with value different from 0, this record will be excluded form the filter set.
Navision Solution Developer
Intelligent Systems Bulgaria
Peter
RIS Plus, LLC
Because the style guide says so (even some of the standard code was reworked in recent versions to comply to these guidelines, Denmark gets it wrong sometimes too) :?
SETRANGE appears to me to be a little bit faster than SETFILTER, noticeably on non-key fields in tables with millions of records .
Secondly I have seen a lot of developers setting filters like this: SETFILTER("Some Field","Some Value") and this causes strange effects when "Some Value" suddenly contains &, * or |. So I always say that you should be careful using SETFILTER and only use it when it can't be done using SETRANGE.
I even do like this: SETRANGE("Some Date Field",TODAY,31129999D) eventhough I know that's not common in the standard application.
Peter
I always use a constant value while filtering "Some Field"... I haven't written a plenty of applications, but I always use "constant" in the "Some Value".
I realized that SETFILTER is not the easiest way in Navision to get along with... yeah better SETRANGE takes a higher priority rather than SETFILTER. (I also don't know their speed)
Jemmy
Other code are not "clean"...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
SETFILTER("Some Field","Some Value") is perfectly legitimate, only you should do it like SETFILTER("Some Field",'=%1',"Some Value"), and use the FORMAT statement as it is appropriate. That way you could also do SETFILTER("Some Field",'=*%1*',"Some Value"), and your wildcards are taken care of right there.
I don't like the use of hard coded artificial end dates. If I need to set a filter on a date I use SETFILTER("Some Date Field",'>=%1',"Some Date Value"). The speed of the query depends on you setting the right key with SETCURRENTKEY.
RIS Plus, LLC