Hi all,
I'm trying to set up a filter on Customer records that limits the user to viewing Customers based on the Responsibility Centre that's associated with the User Setup record. I've written the following code to do this and it works.
//gvUser is a global variable for the User Setup table.
gvUser.GET(USERID);
IF gvUser."Sales Resp. Ctr. Filter" <> '' THEN BEGIN
Rec.SETCURRENTKEY("Responsibility Center");
Rec.SETFILTER("Responsibility Center", gvUser."Sales Resp. Ctr. Filter");
END;
The only problem is when the user clicks the Show All button to clear filters, this filter is cleared and the user can view all Customers.
Is there an easy way to apply this filter when the user logs in and to keep the filter for the duration of the session, even if the user clicks the Show All button?
I'm new to Navision so if anyone has any suggestion regarding an alternative way to limit user access to records, please feel free to share!!
Comments
//gvUser is a global variable for the User Setup table.
gvUser.GET(USERID);
IF gvUser."Sales Resp. Ctr. Filter" <> '' THEN BEGIN
Rec.SETCURRENTKEY("Responsibility Center");
Rec.FILTERGROUP(2);
Rec.SETFILTER("Responsibility Center", gvUser."Sales Resp. Ctr. Filter");
Rec.FILTERGROUP(0);
END;
Filtergroup 2 is just like the filters applied by settableview. In the help it can see so that it serves each group.