0

I am having a sheet that user will be using from its end, having dropdown options "Started, Working, Completed" in Column C. Requirement: Once user have selected "Completed", dropdown must get disabled and no more changes should be possible by user for that cell.

Is there any work around possible for this scenario.

SS : https://docs.google.com/spreadsheets/d/1tmnDOMyupjeO8d65qHQsxb5KrrKeq7pMYIE8h2VmEJ4/edit?usp=sharing

1 Answer 1

2

I believe your goal is as follows.

  • When the user changes the dropdown list of column "C" of "Sheet1" to "Completed", you don't want to make the user change it again.

In this case, how about protecting the cell? When this is reflected in a sample script, it becomes as follows.

Sample script:

In this case, the installable OnEdit trigger is used. So, please install the OnEdit trigger to the function installedOnEdit.

When you use this script, please change the dropdown list of column "C" of "Sheet1" to "Completed" by the user who is not the owner of Spreadsheet. By this, the cell is protected.

In the case of the owner of Spreadsheet, the owner can change the protected dropdown list. When the owner changes the dropdown list from "Completed" to another value, the protection is removed.

function installedOnEdit(e) {
  const range = e.range;
  const sheet = range.getSheet();
  if (sheet.getSheetName() != "Sheet1" || range.columnStart != 3) return;
  const p = sheet.getProtections(SpreadsheetApp.ProtectionType.RANGE).find(r => r.getRange().getRow() == range.rowStart);
  if (!p && range.getValue() == "Completed") {
    const p = range.protect();
    p.removeEditors(p.getEditors());
    if (p.canDomainEdit()) p.setDomainEdit(false);
  } else if (p) {
    p.remove();
  }
}

References:

2
  • Thanks, @Tanaike, that's what exactly needed. Just wanted to know is there any limit of time that script can be triggered? I mean is there any quota set by google for OnEdit calls to script as these script will run infinite times as per my requirement. Jun 15, 2022 at 9:43
  • @Asif Sheikh In the case of the installed OnEdit trigger, the maximum runtime is 6 min / run. When I saw the trigger's total runtime, it seems that currently, 90 min / day and 6 hr / day for Consumer and Google Workspace, respectively. Ref About your limitation in your account, I would like to recommend testing it.
    – Tanaike
    Jun 15, 2022 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.