RESET Function

satish_nav
Member Posts: 65
TestCount := TestRecord.COUNT; //Result TestCount=5;
TestRecord.SETRANGE(TestRecord.ItemNo,TestRecord.ItemNo);
TestCount := TestRecord.COUNT; //Result TestCount=2;
TestRecord.DELETEALL;
TestCount := TestRecord.COUNT; //Result TestCount=0;
TestRecord.RESET;
TestCount := TestRecord.COUNT; //Result TestCount=5;
But when i RESET the record variable then the total records in the TestRecor showing 5 Instead of 3.
Can u help me out Plzzzz.
TestRecord.SETRANGE(TestRecord.ItemNo,TestRecord.ItemNo);
TestCount := TestRecord.COUNT; //Result TestCount=2;
TestRecord.DELETEALL;
TestCount := TestRecord.COUNT; //Result TestCount=0;
TestRecord.RESET;
TestCount := TestRecord.COUNT; //Result TestCount=5;
But when i RESET the record variable then the total records in the TestRecor showing 5 Instead of 3.
Can u help me out Plzzzz.
Thanks in advance..
Satish...
Satish...
0
Comments
-
TestRecord.SETRANGE(TestRecord.ItemNo,TestRecord.ItemNo);
TestCount := TestRecord.COUNT; //Result TestCount=2;
TestRecord.RESET;
TestRecord.DELETEALL;
TestCount := TestRecord.COUNT; //Result TestCount=0;
TestRecord.RESET;
TestCount := TestRecord.COUNT; //Result TestCount=5;
----
Deleteall only deletes all in the filter.0 -
Mark,
Here i want to add the Qty from each record based on ItemNo. and for that i applied SETRANGE with Item Number and i got 2 records. Now i added the qty and then delete the resulted reords and now i reset the record variable for remaining 3 records. But when i reset,
here showing total 5 records as early. Even i used COMMIT also after DELETEALL function.Thanks in advance..
Satish...0 -
Use client monitor to see what happens. I think if you look at the SQL Statements you'll understand.
Also, deleting data like this in a transaction is extremely dangerous and absolutely not best practice. You should reconsider your design.
What is it you are trying to achieve?0 -
satish_nav wrote:TestCount := TestRecord.COUNT; //Result TestCount=5;
TestRecord.SETRANGE(TestRecord.ItemNo,TestRecord.ItemNo);
TestCount := TestRecord.COUNT; //Result TestCount=2;
TestRecord.DELETEALL;
TestCount := TestRecord.COUNT; //Result TestCount=0;
TestRecord.RESET;
TestCount := TestRecord.COUNT; //Result TestCount=5;
Have you used RESET before all this code?
Could your record variable have already filters before this code is reached?0 -
No, I have not used any filters before, on the record variable.
In my table i have records having Item Number and Vendor Number. Based on the vendor Number i want to Create the Quote. If the Item Is repeated for the same Vendor the Qty Should add.
Vend Item Qty
V1 Item1 1
V1 Item1 2
V2 Item2 1
V2 Item2 2
V1 Item3 1
I want to Create Purch Quote Like this
Purch.Quote 1
V1
Item1 3
Item3 1
Purch.Quote 2 ---> V2
Item2 3
I applied only fiter with Item No, and did totalQty count from resulting records and now creaed Purchase Line with that item and the Qty is TotalQty...Now i dont want this resultant records any more so i deleted resultant records with RecVariable.DeleteAll then now i want the remaining records so for that i used RecVariable.RESET, but after this line executed
now getting the all records in this RecVariable including Deleted Records.
Can any body share your experience..Thanks in advance..
Satish...0 -
Well .... this seems just not possible. So it teases my brain. :?
1.
Are you absolutely sure that there are no filters from the beginning?
Markedonly?
Maybe you are overlooking filters in different filtergroups? RESET resets all filters in all filtergroups, and also special filters like MARKEDONLY. It also resets the currentkey to the primary key.
You could do a count from start to make sure.
2.
Your code says DELETEALL. Are you sure that is it not DELETEALL(TRUE)?
In that case code in the OnDelete trigger could cause problems.
3.
The value of TestCount: do you get this value from the debugger?
The debugger might be wrong.
4.
Are you using a dataport? And are you using the trial run (Ctrl+R)?
I believe that Navision doesn't make modifications then.
5.
Maybe you've overlooked something.
Typing mismatches? Are there more recordvariables with similar names?
Code inbetween the code that you posted, which might change filters? Function calls?
Is this code spread over several triggers of functions? In that case: is it a local variable?
Is there also a global variable with the same name?
OK, now I am curious what the problem is or was. Please let me know and set this issue to 'Solved'.Keep It Simple and Stupid (KISS), but never oversimplify.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