Authorization Required in certain Google Sheets users & Script Migrated from Rhino to V8

55 Views Asked by At

My company utilizes Google sheets partially as an inventory system, I am not part of IT but need these sheets to function. Rhino to V8 Image

The top of our scripts shows the message "This script has been successfully migrated from Rhino to V8 runtime on Mar 8, 2023" Can someone convert our Rhino code to V8?

function copyAndDelete() {
  var ss = SpreadsheetApp.openById('1fcR4QMM2TlKDju9prj4UiUR0-oS3YZ0TdeoPS_LWYWc');
  var sheet = ss.getSheetByName("Roll Film");
  var copyRange = sheet.getRange("h4:h44");
  var l = sheet.getDataRange().getValues().length;

  var pasteRange = sheet.getRange("Roll Film!F4:F44");
  pasteRange.setValues(copyRange.getValues());
  copyRange.setFormula("=(f4-i4+g4)");

  var clearadd = sheet.getRange("Roll Film!g4:g44");
  clearadd.setValue("0")

  var cleartaken = sheet.getRange("Roll Film!I4:I44");
  cleartaken.setValue("0")

  };

I am able to update Google sheets with no issues but others are having issues due to authorization requirement tied to their account even with editor rights. I need help converting code from Rhino to V8.

1

There are 1 best solutions below

0
Cooper On

Try this:

function copyAndDelete() {
  var ss = SpreadsheetApp.openById('1fcR4QMM2TlKDju9prj4UiUR0-oS3YZ0TdeoPS_LWYWc');
  var sh = ss.getSheetByName("Roll Film");
  var rg = sh.getRange("h4:h44");
  var prg = sh.getRange("F4:F44");
  prg.setValues(rg.getValues());
  rg.setFormula("=(f4-i4+g4)");
  sh.getRange("g4:g44").setValue("0")
  sh.getRange("I4:I44").setValue("0")
}