Make a field read-only for a role
This example stops Accounts Users from changing the Rate of an Item on a Sales Invoice. They can still see the rate, which comes from the price list. The same steps work for any field and role.
Prerequisites
- The System Manager role.
- You know the permission levels that the document already uses.
Step 1: Put the field on a new level
- Open Customize Form.
- In Enter Form Type, select Sales Invoice Item. The Items table of a Sales Invoice is its own document.
- In the fields table, open the Rate field.
- In Perm Level, enter a level that the document does not use yet, for example
2. - Save.
Step 2: Give the role read access to that level
- Open the Role Permissions Manager.
- Select Add A New Rule.
- Select the Document Type Sales Invoice, the Role Accounts User, and the Permission Level
2. Select Add. - In the new row, select Read only.
Repeat step 2 for every role that must see the field. Give Read and Write to the roles that can change it, for example Accounts Manager.
Step 3: Check the result
Log in as an Accounts User and open a draft Sales Invoice. The Rate of each Item is shown, but the user cannot change it.
Troubleshooting
Error: Permission at level 0 must be set before higher levels are set
You see this message when a role has rules at level 1 or higher, but no rule at level 0 for the same document:
For System Manager at level 2 in Customer in row 8: Permission at level 0 must be set before higher levels are set.
Fix the existing rules of the role named in the message. Do one of these:
- Add a rule for the role at level 0.
- Remove the rules of the role at the higher levels.
Then you can add new rules again.
The field disappeared for everyone
No role has a rule at the new level. Add a rule with Read for every role that must see the field.