Hi Folks,
In this blog we will see how we can set the filters on Page Programmatically i.e, users cannot remove the filter by clicking the “Clear Filter” button.
But if we will not use filtergroup here, only use SetRange then user will clear these filters using "Clear Filters" from Filters Pane.
Sometimes we have to use this feature for security purpose also (Like Users can see the contacts only created by user itself) . Here i am taking example of Contacts. Currently if you open Contacts in Navision it will show you all contacts.
Now add Filter of "SalesPerson Code" is equal to AH along with FilterGroup or any other filter you want,
Also, i am adding Action button named "Contacts (with Filters)" on company Information page to Run Contact List Page based on our filters.
pageextension 50100 "Company Information Extension" extends "Company Information"
{
actions
{
addlast(Processing)
{
action("Contacts (with Filters")
{
ApplicationArea = All;
trigger OnAction()
var
Contacts_Rec: Record Contact;
begin
Contacts_Rec.FilterGroup(10);
Contacts_Rec.SetRange("Salesperson Code", 'AH');
Contacts_Rec.FilterGroup(0);
page.Run(5052, Contacts_Rec);
end;
}
}
}
}
only "Salesperson Code" with value AH contacts is visible now and also user will not able to see or clear filter here.
To Remove the same filters, Use this Code
Contacts_Rec.FilterGroup(10);
Contacts_Rec.SetRange("Salesperson Code", 'AH');
Contacts_Rec.FilterGroup(0);
Contacts_Rec.FilterGroup(10);
Contacts_Rec.SetRange("Salesperson Code");
Contacts_Rec.FilterGroup(0);
page.Run(5052, Contacts_Rec);
Result :- Now it works normally.i.e, All contacts will be visible here:
Stay connected for more articles😏..
Comments
Post a Comment