Delete a record .

Alot of good discussion here so, I’ll add in my 2 cents. Paul is very correct in his statements. Deleting and modifying records while looping through a set of records will usually never cause you any grief EXCEPT when the value you are filtering on is modified. Navision will usually only execute your loop once and return a false when the NEXT command is envoked. Now to my main concern (which is directed at no one and everyone including me): This forum is great and has saved me time on numerous occations. I’d hate to see someone stop posting due to bruised ego. Discussion with and training other Developers is a good. However, let’s keep in mind that we are all professionals. Avoid using phrases like “…you don’t know…”. Bill Benefiel Manager of Information Systems Overhead Door Company billb@ohdindy.com (317) 842-7444 ext 117

William Yes that is the whole point, we never call DELETE on the record variable that we are looping on. We only call DELETE on a copy of the record. So when we call NEXT the record is still set up with it origonal values and the next record is found. If you call DELETE on the looping variable then it is cleared and the NEXT does not work. Paul Baxter

So now we get back to the original post:

quote:


Originally posted by Joseph_Mathew: Hi all I want to delete some rows which are meeting some criteria from a table. This can be done through ProcessingOnly reports. It can be delete records through the following methods. I want to know which method is advisable and why ? Method 1. Dataitem sales OnAfterGetRecord() IF (Sales.DocType =‘Invoice’) and (Sales.Amount = 0 ) THEN DELETE; ELSE CurrReport.SKIP; Method 2. Dataitem: sales Variable: gltblSales Record Sales OnAfterGetRecord() IF Sales.DocType =‘Invoice’ and Sales.Amount = 0 THEN BEGIN IF gltblSales.GET(Sales.DocType,Sales.Nr) Then gltblSales.DELETE; END ELSE CurrReport.SKIP; What I believe is in Method 1. But I had seen the Method 2 in some places. Please let me know which is advisable and why? Regards Joseph MAthew


Paul seems to be saying Method 1 will simply not work. Right? Jim Hollcraft NCSD, NCSP, MCSE, CNE, MCP, MST aka Skater http://drilldot.com Unauthorized Navision News

Alt. 1 will work if You do a CALCFIELDS on the amount field. What You should be careful about is changing fields that is in Your key or filter. If You modify records in the same record variable that You’re looping through You often end up with problems often hard to identify. In this case I’ll do a GET and do the delete on another record variable. //Lars

Moved from “Attain Developer Forum” to “Attain Developer FAQ” forum.