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
0
Comments
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
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.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
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
Gazz
This copies all filter groups. Beware that it copies some other things as well (e.g. marks, current key).
https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-copyfilters-method