0

How to lock Google sheet cell after someone has verified it?

For example, person A input data in A1:C1, then when person B tick checkbox at D1, it will locks A1:C1 to prevent person A from editing again. This process will repeat for every row.

24th Apr 2019, 12:47 AM
Beng Chew
Beng Chew - avatar
3 Respuestas
+ 12
Hello, 😊 If you need help you can post the code you are struggling with!  • SEARCH for similar QUESTIONS or ANSWERS before posting  • Include relevant TAGS  • https://www.sololearn.com/post/75089/?ref=app  • https://code.sololearn.com/WvG0MJq2dQ6y/
24th Apr 2019, 4:30 AM
Danijel Ivanović
Danijel Ivanović - avatar
+ 5
Do you have a code that you have created ? This sounds more like you are asking others to do this...
24th Apr 2019, 1:16 AM
BroFar
BroFar - avatar
0
I am sorry. This is my first post. After some researching and trial, I managed to make my code work. But, it seems like sometimes when person B tick the checkbox quickly, the code may overlook one or two rows and do not lock every row. For example, when person B tick D1, D2 & D3, the system locks 1 and 3 row only. How do I optimize the code so that it will always lock every row without missing one or two? Here is my code. function onEdit(e){ var row = e.range.getRow(); var col = e.range.getColumn(); var range = sheet.getRange(row, 1, 1,3) var protectSs = range.protect().setDescription('Protect row ' + row); var a = sheet.getRange(row,4,1,1).getValues(); if (col == 4){ if (a == "true") { var me = Session.getEffectiveUser(); protectSs.addEditor("guest1@gmail.com"); protectSs.removeEditor("guest1@gmail.com"); Logger.log(me); } else if (a == "false") { protectSs.addEditor("guest1@gmail.com"); protectSs.removeEditor("guest1@gmail.com"); } } }
3rd May 2019, 4:02 AM
Beng Chew
Beng Chew - avatar