Scenario is simple: You as a teamleader managing team attendance in Google Sheet document. Every person should have the ability to edit rows that are only for him. So the person shouldn't be able to edit cells of colleague, but can still enter some data for himself.
Options that Google Sheet provide in the UI are restrictions
to:
All of those options provides ability to add/edit permission for this Restriction
(this is not clear for first time usage). By setting the user himself in here actually cause:
restriction
to him (so the user can still edit sheet)restriction
(this is kinda expected)Question is if there is some way to prevent multiple users from entering multiple cells on same sheet, but he restriction will be applied per user?
Solution I'm looking for can be either from developer or classic user perspective.
I expected something like:
I've visited How to protect ranges per specific users in google sheet? , but as stated above, it only adds editors, where the restriction
is not applied to them.
The reason is that a locking of a sheet has a higher access priority than unlocking of a range.
As a consequence, you will need to use a workaround of splitting your sheet in different ranges and define different permissions for each range.
In your case:
A1:A2
- only user A has accessB1
- only user A has accessB2
- user A and user B have accessC2
- only user B has accessB3:C3
- only user B has accessThe rest of the sheet also needs to be split up in ranges, from which ALL editors need to be removed.
Obviously splitting up of ranges like this is very tedious, however what helps to automatise the process a bit, is using RangeLists.
I can recomend you use the RangeListApp
library developped by @Tanaike.
UPDATE
There is a method called setUnprotectedRanges(ranges) which can overwrite the sheet protection.
Sample:
var protection = sheet.protect().setDescription('Sample protected sheet');
var unprotected = sheet.getRange('B2:C5');
protection.setUnprotectedRanges([unprotected]);
Mind that this method lifts the protection entirely, so you would still need to set a separate protection for the given range to make sure that only 1 user can edit this range.