Filter Group Question

Hello, Note: I am using US Version 2.01. In the Employee Card (form 5200), I am trying to restrict the user from being able to show all records in the Employee Rate list (form 10064). I have added a field in the User Setup table named “Department Filter” which allows the customer to restrict certain users to a given Department Code range. In the Employee Card, OnOpenForm trigger I have placed the following code: UserSetup.GET(USERID); IF (UserSetup.“Department Filter” <> ‘’) THEN BEGIN FILTERGROUP := 2; SETRANGE(“Department Code”,UserSetup.“Department Filter”); FILTERGROUP := 0; END; This filter group successfully filters the department code for me. A further requirement is when the user selects Rates from the Payroll sub-menu on the Employee Card, the RunFormLink only shows Rates for the current Employee. In the Employee Rate (form 10064), I do not want the user to be able to clear the filter and show all Employee Rates. I tried to accomplish this with the following code in the OnOpenForm trigger of the Employee Rate form: FILTERGROUP := 7; // Outside of Internal Navision FilterGroups SETRANGE(“Employee No.”); FILTERGROUP := 0; This code is run on the form, then the OnAfterGetRecord trigger (including code SETRANGE(“No.”):wink: of the Employee Card is run, then my Employee Rate form is displayed. The filter on Employee No. is then able to be cleared. Can anyone suggest a good way of accomplishing this? Thanks, Jack

My question might be stupid but why do you have to use FILTERGROUP at all? I mean, as both forms “Employee” and “Employee Rate” have the same primary key (Employee-No) you could simply use the RunFormLink property to establish a fixed connection. The trick with the FILTERGROUP is usually only necessary if you have filter-criteria which are not part of BOTH tables. Such as the “Department Code”. Marcus ---------------------------------------- Marcus Fabian m.fabian@thenet.ch +41 - 79 - 439 78 72 ----------------------------------------

Marcus, I am trying to keep the user from clearing the filter on Employee number. That is why I am using the filtergroup. Several eyes looked at that code and missed the problem. I did not populate my filter with “Employee No.” setrange(“employee no.”,“employee no.”); I also had to use filtergroup 2 instead of 7. Thanks for your input. Jack

Jack The filter Needs to be Reset on AfterGetRecord I have posted two ways you may be able to solve your problem. The second was used to restrict Users who were set up as Resources from Viewing other Resources Entries, so I know that one works well! Use a function and a variable on the form you are calling and then call it in Code. Sub Form New Variable EmpNo Type:Code Size 20 New Function SetEmpNo(EmployeeNo: Code 20) EmpNo:=EmployeeNo; OnAfterGetRecord() SETRANGE(“Employee No.”,EmpNo); From yor Main Form Variable EmpRates Type:Form SubType “Employee Rates” Form Button C/AL Code OnPush() EmpRates.SetEmpNo(“No.”); EmpRates.Run; The Filter will then be re-Applied when changing the record pointer. Mr David Cox MindSource (UK) Limited Navision Solutions Partner Email: david@mindsource.co.uk Web: www.mindsource.co.uk Edited by - David Cox on 8/6/00 11:50:13 AM Edited by - David Cox on 8/6/00 11:58:06 AM

Just for Information Another way you can use Selection Criteria If you Have the same “User ID” and “Employee No.” and you wanted to restrict the Veiw for the Logged on ID only At form Level Copy the Employee and Employee Rates Forms to New Numbes Both Forms Create a new Function SetTheFilter And a Record Variable Sample Code for Employee Form C/AL Variable Employee1 Type:Record SubType Employee C/AL Trigger Code OnOpenForm() SetTheFilter; OnAfterGetRecord() SetTheFilter; SetTheFilter() Employee1.RESET; Employee1.FILTERGROUP(2); Employee1.SETRANGE(“No.”,USERID); Employee1.FILTERGROUP(0); CurrForm.SETSELECTIONFILTER(Employee1); This will stop the Showall as the filter is reset OnAfterGetRecord Mr David Cox MindSource (UK) Limited Navision Solutions Partner Email: david@mindsource.co.uk Web: www.mindsource.co.uk