MARK won"t mark

asmilie2b3
Member Posts: 40
Hello all,
I am trying to use MARK to mark some entries and then only display them. I haven't used MARK much previously but it would really help now.
I have on a form, the below code in a function which is called from OnAfterGetRecord.
Then, I have a field which for the ondrilldown function uses the below:
I should only see a few entries, but the MARKEDONLY filter is not applied. Can MARKEDONLY not be used when doing a FORM.RUN?
Any thoughts appreciated.
I am trying to use MARK to mark some entries and then only display them. I haven't used MARK much previously but it would really help now.
I have on a form, the below code in a function which is called from OnAfterGetRecord.
PurchCrMemoHeader.RESET; PostedPurchInvoice.SETRANGE("ACW Service Order No.", "No."); IF PostedPurchInvoice.FINDSET THEN REPEAT PurchCrMemoHeader.SETRANGE("Adjustment Applies-to",PostedPurchInvoice."No."); LinkedPostedPCM += PurchCrMemoHeader.COUNT; IF PurchCrMemoHeader.FINDFIRST THEN REPEAT PurchCrMemoHeader.MARK(TRUE); UNTIL PurchCrMemoHeader.NEXT = 0; UNTIL PurchCrMemoHeader.NEXT = 0; PurchCrMemoHeader.SETRANGE("Adjustment Applies-to");
Then, I have a field which for the ondrilldown function uses the below:
PurchCrMemoHeader.MARKEDONLY(TRUE); FORM.RUN(FORM::"Posted Purchase Credit Memos",PurchCrMemoHeader);
I should only see a few entries, but the MARKEDONLY filter is not applied. Can MARKEDONLY not be used when doing a FORM.RUN?
Any thoughts appreciated.
0
Answers
-
It should work. I just tried it and the form shows the markedonly records. Probably something is wrong with your loop.
But on SQL, it is best to avoid MARK because it is a performance killer. It is best to save the records in a temptable and then run the form with the temptable.PurchCrMemoHeaderTemp.RESET; // this is a temptable PurchCrMemoHeaderTemp.DELETEALL(FALSE); PostedPurchInvoice.RESET; // to be sure you don't have other filters on it IF PostedPurchInvoice.SETCURRENTKEY("ACW Service Order No.") THEN ; // try to use a good index for faster searching the records ; the IF THEN avoids an error in case no key exists. PostedPurchInvoice.SETRANGE("ACW Service Order No.", "No."); IF PostedPurchInvoice.FINDSET THEN REPEAT PurchCrMemoHeader.RESET; IF PurchCrMemoHeader.SETCURRENTKEY("Adjustment Applies-to") THEN ; // try to use a good index for faster searching the records PurchCrMemoHeader.SETRANGE("Adjustment Applies-to",PostedPurchInvoice."No."); // LinkedPostedPCM += PurchCrMemoHeader.COUNT; // you scan the records twice: once for the COUNT and once for the FINDSET IF PurchCrMemoHeader.FINDSET THEN // for a loop, NEVER use FINDFIRST, but FINDSET (or FIND('-' / '+') REPEAT // not needed anymore PurchCrMemoHeader.MARK(TRUE); LinkedPostedPCM += 1; // to avoid the COUNT PurchCrMemoHeaderTemp := PurchCrMemoHeader; //NEW LINE PurchCrMemoHeaderTemp.INSERT(FALSE); //NEW LINE UNTIL PurchCrMemoHeader.NEXT = 0; UNTIL PurchCrMemoHeader.NEXT = 0; // PurchCrMemoHeader.SETRANGE("Adjustment Applies-to"); not really needed. It is best to always use RESET-SETCURRENTKEY-SETRANGE/SETFILTER, so you always have all together and can be sure you don't have any filters for other parts of the program. FORM.RUN(FORM::"Posted Purchase Credit Memos",PurchCrMemoHeaderTemp);
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Hello Alain,
Many thanks for your detailed answer. It was my lucky day. I had not known MARK was not good for SQL performance. Point noted. And for several reasons a temptable sounds much better. Easier to debug, more flexibility with sorting etc. I will go with that.
Also thanks for pointing out the anomalies in my code. I was always under the impression that since FINDFIRST was implemented it was better for performance than FIND('+'), but now I see with a loop that is not the case. Also a very elegant method with the IF SETCURRENTKEY(....) THEN.
Much food for thought today, I am humbled.
Bruce Anderson0 -
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
I read that post a couple of years ago, and you know now re-reading it this time it is starting to make sense. Thanks for sharing.0
-
Thanks for the tip... MARK and MARKEDONLY doesnot work, I think it is because ther MARKS dissappear when a form is openend or closed.
But a temporary table... brilliant.
RaymondSimple is simply the best0
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