Google-sheets – Pull data from one sheet (has a locked cell) to another sheet (has a locked cell) every day automatically

google sheetsgoogle-apps-script

I have a dynamic Google spreadsheet to which I add one more sheet every day. I want to take the data from sheet1 cell D96 (a protect cell) to sheet2 cell D3 (a protect cell) every day. I found a script and I edited it to:

function devir() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var sheetidx = sheet.getIndex()-1 ;
  var nextSheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[sheetidx+1];
  var val = nextSheet.getRange('d96').copyTo(sheet.getRange('d3'),{contentsOnly:true})
}

and it is working perfectly with a edit trigger for me (owner) but my problem is that the people with whom I am sharing this document (can edit) get this error:

"There was a problem while You don't have permission for this action"

How can I solve this problem or can I change the script to a custom function? like: write d3 cell =devir(d96) take the data before sheet.

pull the date one page to next page

Best Answer

Instead of using an simple on edit trigger use an installable trigger as it runs with the trigger creator credentials.