Copyfilter from multiple filtergroups

gazpacho
Member Posts: 48
Hi there,
I have a form that displays sales lines. A filter is set on a couple of fields on opening the form. These filters may not be removed, so they are set in filtergroup 0. The user is allowed to further refine the view by setting more filters (in filtergroup 2).
In a function in the sales line table, I want to define a new record variable (salesline2) that has the same filters as the table above.
the code "salesline2.copyfilters(rec)" would seem a logical solution. But this does not work because I have 2 filtergroups on the original table. How can I copy the filters of both filtergroup 0 and 2 to the new record variable?
Best regards
Gazza
I have a form that displays sales lines. A filter is set on a couple of fields on opening the form. These filters may not be removed, so they are set in filtergroup 0. The user is allowed to further refine the view by setting more filters (in filtergroup 2).
In a function in the sales line table, I want to define a new record variable (salesline2) that has the same filters as the table above.
the code "salesline2.copyfilters(rec)" would seem a logical solution. But this does not work because I have 2 filtergroups on the original table. How can I copy the filters of both filtergroup 0 and 2 to the new record variable?
Best regards
Gazza
0
Comments
-
you can loop through filtergroups
for I:= 0 to 255 do begin FILTERGROUP(I); salesline2.FILTERGROUP(I); salesline2.copyfilters(rec) end;
0 -
PS the users should work in filtergroup 0.
Filtergroups 1 to 7 (I think) is reserved by Microsoft.
So put your filters that may not be removed by the user starting from filtergroup 10.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Looping through the filtergroups and perform a copyfilter works fine, but only if the different filtergroups does not contain the same fields.
Example:
In the OnOpenForm trigger, the following filters are set by Navision:
filtergroup(2);
table.SETFILTER(Manager,'%1','JOHN|PETER');
table.SETRANGE(IsOpen,TRUE);
table.SETRANGE(IsPositive,TRUE);
filtergroup(0);
Then, once the user is on the form he narrows this view down to
Manager = PETER by setting a filter.
Thus, the combined filter of groups 0 and 2 is the following:
table.SETFILTER(Manager,'%1','PETER');
table.SETRANGE(IsOpen,TRUE);
table.SETRANGE(IsPositive,TRUE);
When I cycle through the filtergroups and perform a copyfilters() on each group, the final result is that only the filters from the last group are copied. It seems the filters get reset once a copyfilters() is performed
Is there another way?
Best regards
Gazz0 -
salesline2.COPY(rec)
This copies all filter groups. Beware that it copies some other things as well (e.g. marks, current key).0 -
All filters are copied and remain in their assigned group numbers. For example: Rec.CopyFilters(FromRec); disregards the current filter group on both Rec and FromRec, and copies all filters in FromRec (regardless of group number) into the same filter group assignments on Rec.
https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-copyfilters-method0
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