Using an OR filter on a Page with FILTERGROUP(-1) - any issues?
pdj
Member Posts: 643
Say you need to show a list customers either living in the US or having a phone no. starting with +1
Inspired by Luc's article at https://dynamicsuser.net/nav/b/vanvugt/posts/filtergroup-1 I decided to try using the -1 filtergroup. I was very easy setting the filters, and marking the records and show them in the list.
However; that did't quite solve my problem. If the user opens the Customer Card and changes the country code or phone no. it needs to disappear from the list. As I'm using marks I need some way to trigger a reload of the marked records, but there doesn't seem to be any trigger to use.
I then came to think of the old way of showing a temporary record in a form, before the SourceTableTemporary property was introduced. You might recall that method was used in the Navigate form, by adding code in the OnFindRecord() and OnNextRecord() triggers.
I then simply copied this old style code into my NAV2016, and now it works like a charm
My only concern is that I might have overlooked something, and that this approach doesn't work in all scenarios. The performance isn't as good as using marks, but in my case the performance is not an issue. Do you see any other issues with this solution?
Inspired by Luc's article at https://dynamicsuser.net/nav/b/vanvugt/posts/filtergroup-1 I decided to try using the -1 filtergroup. I was very easy setting the filters, and marking the records and show them in the list.
However; that did't quite solve my problem. If the user opens the Customer Card and changes the country code or phone no. it needs to disappear from the list. As I'm using marks I need some way to trigger a reload of the marked records, but there doesn't seem to be any trigger to use.
I then came to think of the old way of showing a temporary record in a form, before the SourceTableTemporary property was introduced. You might recall that method was used in the Navigate form, by adding code in the OnFindRecord() and OnNextRecord() triggers.
I then simply copied this old style code into my NAV2016, and now it works like a charm
My only concern is that I might have overlooked something, and that this approach doesn't work in all scenarios. The performance isn't as good as using marks, but in my case the performance is not an issue. Do you see any other issues with this solution?
Regards
Peter
Peter
0
Answers
-
The only issue I have encountered, is that the filters set by the user was ignored. I fixed that by replacing the simple record assignment with a rec.COPY, but then I also need to assign my own filters all the time. (And then I could delete my code in OnOpenPage)
My code ended up like this:OnFindRecord(Which : Text) : Boolean // >> XXX //g_GlobalRec := Rec; g_GlobalRec.COPY(Rec); f_SetMyFilters; IF NOT g_GlobalRec.FIND(Which) THEN EXIT(FALSE); Rec := g_GlobalRec; EXIT(TRUE); // << XXX OnNextRecord(Steps : Integer) : Integer // >> XXX //g_GlobalRec := Rec; g_GlobalRec.COPY(Rec); f_SetMyFilters; l_CurrentSteps := g_GlobalRec.NEXT(Steps); IF l_CurrentSteps <> 0 THEN Rec := g_GlobalRec; EXIT(l_CurrentSteps); // << XXX LOCAL f_SetMyFilters() // >> XXX WITH g_GlobalRec DO BEGIN FILTERGROUP(-1); SETRANGE("Country Code",'US'); SETFILTER("Phone No.",'+1*'); FILTERGROUP(0); END; // << XXX
PS: The filters are only for the example. The real scenario is a lot more complex
Regards
Peter0 -
Nice solution!
Thank you. You saved a lot of my time.
Works at Dynamics NAV 2017.
Few remarks:
1. Page should have property SourceTableTemporary = Yes
2. Insert / Delete updates list correctly.
3. Consider about support in newer versions (BC, 2019)
0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions