Hi All,
finally found some tim to work on this. I got it all working, and I do have some things to remember. I would ike to summarize them, it might make lifie easier for somebody needing the same functionality:
The case was that Sales people should be able to login in to Navision but their views and actions on data had to be limited to 'their' data. The data sets involved were :
- Contacts
- Customers
- Sales Quotes (create quotes)
- Sales orders (only see sales orders)
1. Permissions
I did make a permission role per sales person (i.e. ACCOUNTMGR_JL). In the concerned tables, I added a permission filter on the salesperson field. i.e. on the contact table, this would be:
Contact: Salesperson Code=JL
In this role, add all other tables necessary, just like you do when setting up permissions.
2. Additional permissions
In addition, you must have a permission role for all sales people(i.e. ACCOUNTMGR_ALL), containing all tables (from the role in step 1) with a record filter. In this additional role, the tables don't have a record filter, and they have all permissions set to 'Indirect'. This additional permission role must be assigned to all sales people. You need to do this one, to solve issues with the fact boxes.
This means that a sales person has two permission roles assigned. ACCOUNTMGR_ALL and ACCOUNTMGR_JL, where JL are the initials of the account manager.
3. Code changes
This is a part of trial and error. I did 3 types of code changes.
a. Tables having a security filter on sales person. In these tables, I had to modify the OnInsert trigger. If a sales person is linked to the user (can be done in the user setup in NAV), then the sales person field defaults to this linked sales person.
b. Solving the 'you do not have acces to ... ' error. Just put on the debugger, check in what object the error raises, and modify the permissions for that object. Add the table specified in the error message. It will Always be one of the tables you have put a permission filter on.
c. if the previous modification doesn't work, you need to add the 'SETPERMISSIONFILTER' statement to the code, just in front of the place you get the error message.