This code works when I use it in the OnLooKup trigger of the 'No. field of a Customer tabel.
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;
However this filter is only applied AFTER the user does a lookup on the field. I need the filter triggered before the users even open the table.
So the question is if I want to put this code in a codeunit instead of in a table how do I reference the table data (Since I don't have a 'Rec' available)? I have tried settuping a global variable, gvCustomer that is of data type 'Record' and has a subtype 'Customer' table. So it looks like:
gvUser.GET(USERID);
IF gvUser."Sales Resp. Ctr. Filter" <> '' THEN BEGIN
gvCustomer.SETCURRENTKEY("Responsibility Center");
gvCustomer.FILTERGROUP(2);
gvCustomer.SETFILTER("Responsibility Center", gvUser."Sales Resp. Ctr. Filter");
gvCustomer.FILTERGROUP(0);
END;
However this runs error free but does not do anything.
Thanks.
0
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
The reason we want to set the filter in a codeunit is so we can put it in one place (e.g in the CompanyOpen function in the Application Management codeunit) where it will be applied for all users all the time no matter what form they use to access the table. Or course if it can't be done via a codeunit then we will need to look at useing forms. Thanks.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.